This topic describes how to use the utf8mb4 character set to store emoticons.
Alibaba Cloud reminds you that:
- When you perform operations that have risks, such as modifying instances or data, check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
- Before you modify the configurations and data of instances including but not limited to ECS and RDS instances, we recommend that you create snapshots or enable RDS log backup.
- If you have authorized or submitted security information such as the logon account and password in the Alibaba Cloud Management console, we recommend that you modify such information in a timely manner.
To store emoticons to an apsaradb RDS for MySQL instance, you must use or support the utf8mb4 character set on the client, the application-to-RDS instance connection, and within the instance.
- Client: make sure that the character set of the output string is utf8mb4 on the client.
- Connection between the application and RDS instance: Supports the utf8mb4 character set. For example, to establish a common JDBC connection, you must use MySQL Connector/J 5.1.13 or later versions. In the JDBC connection string, we recommend that you do not configure characterEncoding.
- RDS instance configuration: Set the character_set_server in the console to utf8mb4, the character set of the database to utf8mb4, and the character set of the table to utf8mb4.
set names command set session character set
If the characterEncoding of the JDBC connection string is set to utf8, or emoji data cannot be inserted after the preceding configuration, we recommend that you specify the character set of the JDBC connection string to utf8mb4 in the code. The sample code is as follows:
String query = "set names utf8mb4"; stat.execute(query);
- Apsaradb for MySQL