This topic describes how to change the character set for an ApsaraDB RDS for MySQL instance.
Procedure
Connect to the RDS instance by using the CLI or a client. For more information, see Use a client or the CLI to connect to an ApsaraDB RDS for MySQL instance.
Execute the following statements in the SQL window to change the character set for the RDS for MySQL instance:
Change the character set for a database: ALTER DATABASE <Database name> CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci; Change the character set for a table: ALTER TABLE <Table name> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; Change the character set for a column: ALTER TABLE <Table name> CHANGE <Column name> <Data type> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;NoteFor more information about how to change the character set on the client, see Guarantee the availability of database character encoding for an ApsaraDB RDS for MySQL instance.
FAQ
What do I do if the "Unsupported collation on string indexed column XXX.Consider change to other collation" error message is displayed?
The error message is displayed because an indexed string column does not support specific collations when you manage the column. You can execute the following statements to view and modify the collation of the column to resolve the error:
Query the collation of the column.
SHOW FULL COLUMNS FROM <Table name>;Change the collation of the column.
ALTER TABLE <Table name> CHANGE <Column name> <Data type> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;