Documentation Home
MySQL 9.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 41.9Mb
PDF (A4) - 42.0Mb
Man Pages (TGZ) - 272.3Kb
Man Pages (Zip) - 378.3Kb
Info (Gzip) - 4.2Mb
Info (Zip) - 4.2Mb


MySQL 9.7 Reference Manual  /  ...  /  The utf8 Character Set (Deprecated alias)

12.9.3 The utf8 Character Set (Deprecated alias)

utf8 is a deprecated alias whose interpretation in SQL statements is controlled by the `INTERPRET_UTF8_AS_UTF8MB4` SQL mode. When the server stores or reports a resolved character set or collation, it uses the canonical `utf8mb3` or `utf8mb4` name rather than `utf8`. For more information, see Section 12.9.1, “The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)” and Section 12.9.2, “The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)”.

The alias mapping is as follows:

Table 12.3 utf8 Alias Mapping INTERPRET_UTF8_AS_UTF8MB4

SQL mode utf8 utf8_xxx

INTERPRET_UTF8_AS_UTF8MB4 not enabled (default)

utf8mb3

utf8mb3_xxx

INTERPRET_UTF8_AS_UTF8MB4 enabled

utf8mb4

utf8mb4_xxx


Character set and collation names are not case-sensitive. For example, `UTF8`, `Utf8`, and `utf8` are interpreted identically. The mapping applies to character set and collation names in DDL and DML statements. DDL stores the resolved canonical names, which are displayed by `SHOW CREATE` statements. `EXPLAIN` reflects names resolved while processing DML statements. For example:

SET SESSION sql_mode = '';
CREATE TABLE t1 (c VARCHAR(10))
  CHARACTER SET utf8 COLLATE utf8_bin;
SHOW CREATE TABLE t1;

SET SESSION sql_mode = 'INTERPRET_UTF8_AS_UTF8MB4';
CREATE TABLE t2 (c VARCHAR(10))
  CHARACTER SET utf8 COLLATE utf8_bin;
SHOW CREATE TABLE t2;

t1 uses utf8mb3 and utf8mb3_bin; while t2 uses utf8mb4 and utf8mb4_bin.

All utf8mb3 collations have a corresponding utf8mb4 collation except utf8mb3_general_mysql500_ci and utf8mb3_tolower_ci. Consequently, utf8_general_mysql500_ci and utf8_tolower_ci are rejected when INTERPRET_UTF8_AS_UTF8MB4 is enabled. Specify the corresponding utf8mb3 name explicitly to use either collation. For generated columns, aliases are resolved to explicit character set and collation names when the table is created.

INTERPRET_UTF8_AS_UTF8MB4 does not affect the following:

To avoid behavior that depends on the SQL mode, it is recommended to specify utf8mb3 or utf8mb4 explicitly.

Note

The recommended character set for MySQL is utf8mb4. All new applications should use utf8mb4.

The utf8mb3 character set is deprecated. utf8mb3 remains supported for the lifetimes of the MySQL 8.4.x LTS release series.

Expect utf8mb3 to be removed in a future major release of MySQL.

Since changing character sets can be a complex and time-consuming task, you should begin to prepare for this change now by using utf8mb4 for new applications. For guidance in converting existing applications which use utfmb3, see Section 12.9.8, “Converting Between 3-Byte and 4-Byte Unicode Character Sets”.