如何将整个MySQL数据库字符集转换为UTF-8并将排序规则转换为UTF-8?
使用ALTER DATABASE和ALTER TABLE命令。
ALTER DATABASE
ALTER TABLE
ALTER DATABASE databasename CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
或者,如果您仍在不支持4字节UTF-8的MySQL 5.5.2或更早版本上,请使用utf8代替utf8mb4:
utf8
utf8mb4
ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci; ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;