Background:
When writing a data db operation, the log illegal mix of collations (latin1_swedish_ci,coercible) and (gbk_chinese_ci,coercible) for operation ' = ' Error
Reason:
1. The data type in the plug-in code is GBK;
2, DB Build table forget to change the default encoding format (default is COLLATION:LATIN1_SWEDISH_CI format);
1, 2 after combining, insert data encoding error;
Positioning method:
1. View the field code of the DB table show full columns from TableName;
2. Check the Struts code
Modification Method:
1, modify the Database DB field settings;
mysql> SHOW VARIABLES like ' character_set_% ';
+--------------------------+----------------------------+
| variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | Latin1 |
| character_set_connection | Latin1 |
| Character_set_database | Latin1 |
| Character_set_results | Latin1 |
| Character_set_server | Latin1 |
| Character_set_system | UTF8 |
| Character_sets_dir | /usr/share/mysql/charsets/|
+--------------------------+----------------------------+
7 Rows in Set (0.00 sec)
mysql> SHOW VARIABLES like ' collation_% ';
+----------------------+-------------------+
| variable_name | Value |
+----------------------+-------------------+
| collation_connection | Latin1_swedish_ci |
| Collation_database | Latin1_swedish_ci |
| Collation_server | Latin1_swedish_ci |
+----------------------+-------------------+
3 Rows in Set (0.00 sec)
Execute in turn:
Set Character_set_client =GBK;
Set Character_set_connection =GBK;
Set Character_set_database =GBK;
Set Character_set_results =GBK;
Set Character_set_server =GBK;
Set Character_set_system =GBK; --Here utf-8 can also
Then execute:
SET Collation_server = Gbk_chinese_ci
SET collation_database = Gbk_chinese_ci
SET collation_connection =gbk_chinese_ci
Daily problem record-insert record times illegal mix of collations (latin1_swedish_ci,coercible) and (gbk_chinese_ci,coercible) for operation ' = ' Error