ERROR 1366 (HY000): Incorrect string value: ' \xe7\x9a\x84 ' for column ' name ' at row 1

Source: Internet
Author: User
mysql> insert into t3 (id,name) VALUES (1, ');

ERROR 1366 (HY000): Incorrect string value: ' \xe7\x9a\x84 ' for column ' name ' at row 1


Checking whether the character set of this field in the database is the same as the character set that the SQL statement passes data to, and the difference raises a MySQL1366 error.

Mysql> show full columns from T3;
+-------+-------------+-------------------+------+-----+---------+-------+---------------------------------+--- ------+
| Field | Type | Collation | Null | Key | Default | Extra | privileges | Comment |
+-------+-------------+-------------------+------+-----+---------+-------+---------------------------------+--- ------+
| ID | Int (11) | NULL | NO | PRI |       NULL | |         select,insert,update,references | |
| name | varchar (30) | Latin1_swedish_ci |     YES | |       NULL | |         select,insert,update,references | |
+-------+-------------+-------------------+------+-----+---------+-------+---------------------------------+--- ------+

To see that the Name column is of type Latin, change name to UTF8:

mysql> ALTER TABLE t3 modify name varchar (a) character set UTF8;
Query OK, 1 row affected (0.06 sec)
Records:1 duplicates:0 warnings:0


Mysql> show full columns from T3;
+-------+-------------+-----------------+------+-----+---------+-------+---------------------------------+----- ----+
| Field | Type | Collation | Null | Key | Default | Extra | privileges | Comment |
+-------+-------------+-----------------+------+-----+---------+-------+---------------------------------+----- ----+
| ID | Int (11) | NULL | NO | PRI |       NULL | |         select,insert,update,references | |
| name | varchar (30) | Utf8_general_ci |     YES | |       NULL | |         select,insert,update,references | |
+-------+-------------+-----------------+------+-----+---------+-------+---------------------------------+----- ----+
2 rows in Set (0.00 sec)


mysql> insert into t3 (id,name) VALUES (3, ');
Query OK, 1 row Affected (0.00 sec)


Mysql> select * from T3;
+----+------+
| ID | name |
+----+------+
| 1 | Dan |
| 3 | of |


--This article references from: http://blog.csdn.net/clare504/article/details/9569347

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.