java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_...

# java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='

建了视图,可是查询报错,如上
检查视图中所包含的表发现其中一个建表时 没有设置编码,并且其他的表设置的是 CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;因此导致混乱;

查看当前数据库的默认编码:
mysql> show variables where Variable_name like 'collation%';


image.png

查看各表编码:
mysql> show create table ‘table_name’;

解决方案给没有设置编码的表重新设置一下:

mysql> alter table table_name default character set utf8mb4 collate=utf8mb4_general_ci;

这样设置只针对表的,但是表中字段未修改:

mysql> ALTER TABLE table_name convert to CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容