1. 程式人生 > >Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT)--異常3

Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT)--異常3

情景:在遷移資料庫部分表後,報瞭如下字符集錯誤:

java.sql.SQLException: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT)for operation '='

 分析原因:

utf8_general_ci和utf8_unicode_ci是字元的校對規則比較,原先表使用的是utf8_general_ci,遷移過來成utf8_unicode_ci,所以查詢時報錯啦。

解決辦法:

既然是字符集問題,只需修改一下表的字符集就可以瞭如下:

alter table sys_user convert to character set utf8 collate utf8_general_ci;