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