Relational Database Service (MySQL)

Configuring the Character Set of MySQL Instance

2024-06-21 08:23:47

To fully support the utf8mb4 character set and store emoji expressions, you need to conduct the corresponding configuration in the MySQL instance.

• Modifying parameters on the console: Log in to the Console, go to the Instance Management page, and select the target instance. Click Parameter Setting, find the character_set_server parameter and change its value to utf8mb4. Save the modified parameter settings.

 

• Setting the database character set: When you create the database, explicitly specify the character set to utf8mb4 and grant the database access permissions for the relevant account.

 

• Configuring the character set for the table: When creating or modifying a table, explicitly specify the character set of the table to utf8mb4 and ensure that the data in the table can correctly store and display emoji expressions.

 

If the character set and comparison rule are not explicitly specified when creating or modifying a column, the column defaults to use the character set and comparison rule of the table. Similarly, if the character set and comparison rule are not explicitly specified when creating or modifying a table, the table defaults to use the character set and comparison rule of the database. If the character set and comparison rule are not explicitly specified when creating or modifying a database, the database defaults to use the character set and comparison rule of the server.

Through the above settings, the risk of garbled characters can be effectively reduced, and it is possible to store and display complex Chinese characters and emoji expressions in MySQL instances.

In summary, it is recommended to select the utf8mb4 character set when creating the MySQL instance and ensure that the character sets are uniformly configured for the clients, session connections, and MySQL instances. Using uniform utf8mb4 character sets ensures a better user experience and avoids garbled characters due to character set mismatches.

² Note

Modifying character sets and comparison rules may increase data storage space, but will not affect the quality and compatibility of existing data.


5jQdQYvKgid6