From 9609b48b9149aa0b96208588b99ce6161be6a287 Mon Sep 17 00:00:00 2001 From: Ben Cail Date: Thu, 17 Oct 2024 16:32:36 -0400 Subject: Fixed #18392 -- Changed default mysql encoding to "utf8mb4". --- docs/ref/contrib/auth.txt | 5 +---- docs/ref/databases.txt | 18 +++++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'docs/ref') 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 - `. 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. + `. .. 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 CHARACTER SET utf8; + CREATE DATABASE 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``. -- cgit v1.3