小编典典

如何将整个MySQL数据库字符集和排序规则转换为UTF-8?

mysql

如何将整个MySQL数据库字符集转换为UTF-8并将排序规则转换为UTF-8?


阅读 375

收藏
2020-05-17

共1个答案

小编典典

使用ALTER DATABASEALTER 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

ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
2020-05-17