參考:https://www.cnblogs.com/minutes/p/10808026.html
報錯:java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='
原因:幾張表關(guān)聯(lián)的時候玛臂,如果表的字符集不一致橡疼,就會出現(xiàn)這樣的問題
幾步走:
1、查看字符集配置
show VARIABLES WHERE variable_name like '%collation%'
2、看一下關(guān)聯(lián)的表使用的是什么字符集:
show create table xx_table;
3、修改表字符集:
alter table xx_table1 default character set utf8mb4 collate=utf8mb4_0900_ai_ci ;
4、修改字段的字符集:
有時候只改表的字符集是不行的,還需要改字段的字符集
ALTER TABLE xx_table2 convert to CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;