我使用 MySQL 表,在创建它时为整个表指定CHARACTER SET=utf8mb4 COLLATE=utf8mb4_bin。除大写“I”外,西里尔字母均已成功处理。
mysql> select count(*) from bashorg where rstr="Гы";
+----------+
| count(*) |
+----------+
| 1 |
+----------+
1 row in set (0,00 sec)
mysql> select count(*) from bashorg where rstr="Иа";
ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_bin,IMPLICIT) and (cp1251_general_ci,COERCIBLE) for operation '='
mysql> select count(*) from bashorg where rstr="И";
ERROR 1267 (HY000): Illegal mix of collations (utf8mb4_bin,IMPLICIT) and (cp1251_general_ci,COERCIBLE) for operation '='
对一个字母“I”的这种歧视从何而来?
原来在服务器上设置了连接编码“cp1251”。
要修复错误,您可以更改服务器配置,或者在每个会话开始时,执行