When you store emojis in an ApsaraDB RDS for MySQL instance, the error code [1366]; Incorrect string value: 'xx' or General error: 3988 Conversion from collation utf8mb3_general_ci into utf8mb4_general_ci impossible for parameter error message may be displayed. The cause is that a character in the UTF-8 character set supports up to 3 bytes. However, 4 bytes are required to store an emoji. In this case, you can use the utf8mb4 character set to store emojis.
Compatibility requirements
To store emojis in an RDS instance, you must use the utf8mb4 character set for the following components:
Client: The client uses the utf8mb4 character set for the output strings.
Database connection layer: The utf8mb4 character set is supported. For example, if you create JDBC connections, make sure that the following requirements are met:
The MySQL Connector/J driver runs version 5.1.13 or later.
You do not configure the
characterEncodingparameter for the JDBC connection strings.
RDS instance:
Configure instance parameters in the ApsaraDB RDS console: You must use the
character_set_server = utf8mb4setting.Database objects:
ALTER DATABASE db_name CHARACTER SET utf8mb4; ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4;
Character set change
If the character set does not meet your business requirements, you can change the character set based on the following priority:
Instance-level parameter
character_set_serverDatabase character set
Table character set
Field character set
After you change the character set from utf8 to utf8mb4, take note of the following points:
The data compatibility is not affected.
You can store emojis for new data.
The estimated data storage is increased.