设置collation_database collation_server

写入mysql数据库时tomcat报错:Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation ‘=

数据库字符集的不相符的问题:
用navicat打开数据库的命令行:
如图:
设置collation_database collation_server_第1张图片
输入显示字符集命令:
设置collation_database collation_server_第2张图片

mysql>SHOW VARIABLES LIKE '%colla%';

+———————-+——————–+
| Variable_name | Value |
+———————-+——————–+
| collation_connection | utf8mb4_general_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_general_ci |
+———————-+——————–+
3 rows in set (0.06 sec)

mysql> set collation_server=utf8_unicode_ci;
Query OK, 0 rows affected (0.24 sec)

mysql>SHOW VARIABLES LIKE '%colla%';

+———————-+—————–+
| Variable_name | Value |
+———————-+—————–+
| collation_connection | utf8_general_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+———————-+—————–+
3 rows in set (0.20 sec)

mysql> set collation_connection=utf8_unicode_ci;
Query OK, 0 rows affected (0.17 sec)

mysql>SHOW VARIABLES LIKE '%colla%';

+———————-+—————–+
| Variable_name | Value |
+———————-+—————–+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+———————-+—————–+
3 rows in set (0.10 sec)

你可能感兴趣的:(设置collation_database collation_server)