当前位置: 代码迷 >> 综合 >> mysql报错【Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_german2_ci,IMPLICIT) for oper
  详细解决方案

mysql报错【Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_german2_ci,IMPLICIT) for oper

热度:98   发布时间:2023-12-22 15:25:28.0

1,可以直接在建表时添加ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_german2_ci

2,修改默认的COLLATE

mysql> SHOW VARIABLES LIKE 'collation_%';
+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_german2_ci |
| collation_server     | utf8_german2_ci |

mysql> set collation_connection=utf8_german2_ci;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE 'collation_%';
+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_german2_ci |
| collation_database   | utf8_german2_ci |
| collation_server     | utf8_german2_ci |
+----------------------+-----------------+
3 rows in set, 1 warning (0.00 sec)

这样建表默认使用utf8_german2_ci

 

 

 

  相关解决方案