Navicat 处理数据的时候出现了这个异常:
Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation ‘=‘
原因:
mysql8.0.1之后的默认COLLATE为utf8mb4_0900_ai_ci;表存在不同的编码导致;
经查阅得知解决方法如下:
1、查看编码:show variables where Variable_name like ‘collation%‘ or Variable_name like ‘character_set_server%‘;
2、修改服务器编码:修改my.ini文件, 一般在ProgramData文件夹里,我的路径为:C:ProgramDataMySQLMySQL Server 8.0,打开my.ini在里面添加:
[mysqld]
character_set_server=utf8mb4
collation_server=utf8mb4_general_ci
3、重启mysql: 到任务管理器--》服务--》mysql 右键重启,
4、修改表的编码:alter table table_name default character set utf8mb4 collate=utf8mb4_general_ci;
5、修改字段的编码: ALTER TABLE table_name convert to CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
参考文档:
https://www.cnblogs.com/joeblackzqq/p/4521260.html
https://www.cnblogs.com/minutes/p/10808026.html