MySQL 5.5 upgrades the character set from utf8 to utf8mb4
Reason for upgrade
MySQL supports only three-byte UTF-8 characters by default, and does not support Emoji emoticons (four bytes). If there are four-byte characters, an error is returned. MySQL 5.5 and later versions provide utf8mb4, which supports four-byte characters.
Many iphone users add Emoji when entering nicknames. If MySQL does not use the utf8mb4 character set, such nickname information cannot be written.
1. Before upgrade.
Mysql> show variables like 'character _ set % ';
+ Bytes + | Variable_name | Value | + bytes + | character_set_client | utf8 | character_set_connection | utf8 | character_set_database | utf8 | bytes | binary | utf8 | | character_set_server | utf8 | character_set_system | utf8 | character_sets_dir |/home/sdkserver/local/mysql-5.5.43-linux2.6-x86_64/share/charsets/| + rows + 8 rows in set (0.00 sec)
Mysql> show variables like 'collation % ';
+ Rows + --------------- + | Variable_name | Value | + rows + --------------- + | collation_connection | rows | collation_database | rows | collation_server | rows | + rows + 3 rows in set (0.00 sec)
2. modify the configuration file.
Open the MySQL configuration file and modify the character set configuration as follows:
[Client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSEcharacter-set-server = utf8mb4collation-server = Login = 'set NAMES utf8mb4'
3. After the upgrade.
Mysql> show variables like 'character _ set % ';
+ Bytes + | Variable_name | Value | + bytes + | bytes | utf8mb4 | character_set_connection | utf8mb4 | character_set_database | utf8mb4 | bytes | binary | bytes | utf8mb4 | | character_set_server | utf8mb4 | character_set_system | utf8 | character_sets_dir |/home/nieyong/local/mysql-5.5.43/share/charsets/| + rows + 8 rows in set (0.00 sec)
Mysql> show variables like 'collation % ';
+ Rows + ------------------ + | Variable_name | Value | + rows + -------------------- + | collation_connection | rows | collation_database | rows | collation_server | rows | + rows + 3 rows in set (0.00 sec)
This article permanently updates the link address: