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 |
|---|---|---|
|
|
|
|
|
|
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:
For MySQL client program options,
--default-character-set=utf8always selects utf8mb3.For external character set definitions read from
Index.xml,utf8continues to map toutf8mb3.Server startup options require explicit names.
--default-character-set=utf8,--default-character-set=utf8, and--collation-server=utf8_xxxare rejected. Use explicitutf8mb3,utf8mb4,utf8mb3_xxx, orutf8mb4_xxxnames instead.
To avoid behavior that depends on the SQL mode, it is
recommended to specify utf8mb3 or
utf8mb4 explicitly.
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”.