0
点赞
收藏
分享

微信扫一扫

Error 1267 Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT

骨灰级搬砖工 2022-01-28 阅读 105


Mysql 报错: `Error 1267 Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation ‘=’

1.问题

mysql字符集不匹配导致比较时出错。

这种问题可能出现在Mysql函数,存储过程运行时

2.原因

使用的mysql的字符集与表中字段的字符集不一致。

这里的utf8mb4_unicode_ci和utf8mb4_general_ci是两种字符集排序方式。【其中的c指的就是​​Collation:排序规则​​】

3.解决方法


  • 在使用的​​varchar​​​ 类型字段中添加字符排序方式:​​select * from user where mobile = in_mobile COLLATE utf8_unicode_ci;​
  • 或者直接修改my.cnf文件,在[mysqld]中添加默认的字符集排序方式


[mysqld]
character-set-server=utf8
collation-server=utf8mb4_general_ci[###或者是utf8mb4_unicode_ci]

参考链接

  • ​​https://dev.mysql.com/doc/refman/5.7/en/charset-applications.html​​


举报

相关推荐

0 条评论