无法将表字符集编码从latin1_swedish_ci更改为utf8mb4_bin

时间:2016-04-01 08:55:56

标签: mysql

通过此查询尝试alter table

 ALTER TABLE `outlooks` CHANGE `description` `description` TEXT    CHARSET=utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL;

但是收到错误

 #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL' at line 1

1 个答案:

答案 0 :(得分:0)

这不是正确的语法。关于问题所在的错误也很清楚。

根据the manual,它应该看起来像:

ALTER TABLE `outlooks`
CHANGE `description`
`description` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL;

然而,这不会将数据表的内容从ISO-8859-1转换为UTF8。您可能looking for

ALTER TABLE `outlooks` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;