diff options
| author | Ben Cail <bcail@crossway.org> | 2024-10-17 16:32:36 -0400 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-11-18 15:00:33 +0100 |
| commit | 9609b48b9149aa0b96208588b99ce6161be6a287 (patch) | |
| tree | fa1e78c632c00a063a751bed8b4b52d29d6df004 /docs | |
| parent | 2debd018dbc7aba0b98b4c082bbb1fa1d195a47e (diff) | |
Fixed #18392 -- Changed default mysql encoding to "utf8mb4".
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/auth.txt | 5 | ||||
| -rw-r--r-- | docs/ref/databases.txt | 18 | ||||
| -rw-r--r-- | docs/releases/5.2.txt | 12 |
3 files changed, 21 insertions, 14 deletions
diff --git a/docs/ref/contrib/auth.txt b/docs/ref/contrib/auth.txt index 103aff8e0b..3e1cdfd978 100644 --- a/docs/ref/contrib/auth.txt +++ b/docs/ref/contrib/auth.txt @@ -30,10 +30,7 @@ Fields The ``max_length`` should be sufficient for many use cases. If you need a longer length, please use a :ref:`custom user model - <specifying-custom-user-model>`. If you use MySQL with the ``utf8mb4`` - encoding (recommended for proper Unicode support), specify at most - ``max_length=191`` because MySQL can only create unique indexes with - 191 characters in that case by default. + <specifying-custom-user-model>`. .. attribute:: first_name diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index 73a67475fe..57e94140c2 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -517,7 +517,7 @@ You can `create your database`_ using the command-line tools and this SQL: .. code-block:: sql - CREATE DATABASE <dbname> CHARACTER SET utf8; + CREATE DATABASE <dbname> CHARACTER SET utf8mb4; This ensures all tables and columns will use UTF-8 by default. @@ -542,21 +542,21 @@ Django doesn't provide an API to change them. .. _documented thoroughly: https://dev.mysql.com/doc/refman/en/charset.html By default, with a UTF-8 database, MySQL will use the -``utf8_general_ci`` collation. This results in all string equality +``utf8mb4_0900_ai_ci`` collation. This results in all string equality comparisons being done in a *case-insensitive* manner. That is, ``"Fred"`` and ``"freD"`` are considered equal at the database level. If you have a unique constraint on a field, it would be illegal to try to insert both ``"aa"`` and ``"AA"`` into the same column, since they compare as equal (and, hence, non-unique) with the default collation. If you want case-sensitive comparisons on a particular column or table, change the column or table to use the -``utf8_bin`` collation. +``utf8mb4_0900_as_cs`` collation. Please note that according to `MySQL Unicode Character Sets`_, comparisons for -the ``utf8_general_ci`` collation are faster, but slightly less correct, than -comparisons for ``utf8_unicode_ci``. If this is acceptable for your application, -you should use ``utf8_general_ci`` because it is faster. If this is not acceptable -(for example, if you require German dictionary order), use ``utf8_unicode_ci`` -because it is more accurate. +the ``utf8mb4_general_ci`` collation are faster, but slightly less correct, +than comparisons for ``utf8mb4_unicode_ci``. If this is acceptable for your +application, you should use ``utf8mb4_general_ci`` because it is faster. If +this is not acceptable (for example, if you require German dictionary order), +use ``utf8mb4_unicode_ci`` because it is more accurate. .. _MySQL Unicode Character Sets: https://dev.mysql.com/doc/refman/en/charset-unicode-sets.html @@ -602,7 +602,7 @@ Here's a sample configuration which uses a MySQL option file:: database = NAME user = USER password = PASSWORD - default-character-set = utf8 + default-character-set = utf8mb4 Several other `MySQLdb connection options`_ may be useful, such as ``ssl``, ``init_command``, and ``sql_mode``. diff --git a/docs/releases/5.2.txt b/docs/releases/5.2.txt index a977e6c803..3cc71b7f68 100644 --- a/docs/releases/5.2.txt +++ b/docs/releases/5.2.txt @@ -174,7 +174,9 @@ CSRF Database backends ~~~~~~~~~~~~~~~~~ -* ... +* MySQL connections now default to using the ``utf8mb4`` character set, + instead of ``utf8``, which is an alias for the deprecated character set + ``utf8mb3``. Decorators ~~~~~~~~~~ @@ -385,6 +387,14 @@ Dropped support for PostgreSQL 13 Upstream support for PostgreSQL 13 ends in November 2025. Django 5.2 supports PostgreSQL 14 and higher. +Changed MySQL connection character set default +---------------------------------------------- + +MySQL connections now default to using the ``utf8mb4`` character set, instead +of ``utf8``, which is an alias for the deprecated character set ``utf8mb3``. +``utf8mb3`` can be specified in the ``OPTIONS`` part of the ``DATABASES`` +setting, if needed for legacy databases. + Miscellaneous ------------- |
