Mysql 字符集 Illegal mix of collations

java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='

java.sql.SQLSyntaxErrorException: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'lat1n'


###########

mysql> alter database db default character set utf8;
Query OK, 1 row affected (0.00 sec) 

mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql>  set character_set_database=utf8mb4;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> set character_set_client=utf8mb4;
Query OK, 0 rows affected (0.00 sec)

mysql>  set character_set_connection=utf8mb4;
Query OK, 0 rows affected (0.00 sec)

mysql>  set character_set_filesystem=utf8mb4;
Query OK, 0 rows affected (0.00 sec)

mysql>  set character_set_server=utf8mb4;
Query OK, 0 rows affected (0.00 sec)

mysql>  set character_set_results=utf8mb4;
Query OK, 0 rows affected (0.00 sec)

mysql>  set character_set_system=utf8mb4;

mysql> show variables like 'collation%';
+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)

mysql> set collation_database=utf8_general_ci;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> set collation_server=utf8_general_ci;
Query OK, 0 rows affected (0.00 sec)

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

mysql> alter table xxx convert to character set utf8 collate utf8_general_ci;
Query OK, 0 rows affected (0.04 sec)
Records: 0  Duplicates: 0  Warnings: 0

你可能感兴趣的:(mysql,mysql)