Let MySQL support Emoji expressions. We recommend that you use the utf8mb4 character set in advance for MySQL databases involving wireless connections. What is the difference between utf8mb4 and utf8? Previous
Let MySQL support Emoji expressions. We recommend that you use the utf8mb4 character set in advance for MySQL databases involving wireless connections. What is the difference between utf8mb4 and utf8? Previous
Let MySQL support Emoji expressions. We recommend that you use the utf8mb4 character set in advance for MySQL databases involving wireless connections.
What is the difference between utf8mb4 and utf8? In the past, mysql utf8 had a maximum of 3 characters, while utf8mb4 was extended to a single character with a maximum of 4 bytes. Therefore, more character sets are supported.
Solution: Convert Mysql encoding from utf8 to utf8mb4.
Required> = MySQL 5.5.3 and slave database must also be 5.5. Earlier versions do not support this character set or duplicate error.
Stop the MySQL Server Service
Modify my. cnf or mysql. ini
[Client]
Default-character-set = utf8mb4
[Mysql]
Default-character-set = utf8mb4
[Mysqld]
Character-set-client-handshake = FALSE
Character-set-server = utf8mb4
Collation-server = utf8mb4_unicode_ci
Init_connect = 'set NAMES utf8mb4'
Restart MySQL Server and check Character Set
Mysql> show variables where Variable_name LIKE 'character \ _ set \ _ % 'OR Variable_name LIKE 'colation % ';
Modify the database character set:
Alter database database_name character set = utf8mb4 COLLATE = utf8mb4_unicode_ci;
Modify the character set of a table:
Alter table table_name convert to character set utf8mb4 COLLATE utf8mb4_unicode_ci;
Modify the character set of a field:
Alter table table_name CHANGE column_name VARCHAR (191) character set utf8mb4 COLLATE utf8mb4_unicode_ci;
If you only need to modify the character set of a field
In addition, do not add the characterEncoding parameter to the connection parameters of the server connection Database Connector/J. If this parameter is not added, the default value is autodetect.
This article permanently updates the link address: