Daily problem record-insert record times illegal mix of collations (latin1_swedish_ci,coercible) and (gbk_chinese_ci,coercible) for operation ' = ' Error

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.