ERROR 1366 (HY000): Incorrect string value: '\xE5\xB8\x82' for column 'address' at row 1

时间:2023-02-04 17:09:14

1、错误描述

mysql> insert into t_student_info values (2016010101,'张三',23,'男','2323254343','湖北省武汉市洪山区');
ERROR 1366 (HY000): Incorrect string value: '\xE5\xBC\xA0\xE4\xB8\x89' for column 'name' at row 1
mysql> insert into t_student_info values (2016010101,'张三',23,'男','2323254343','湖北省武汉市洪山区');
ERROR 1366 (HY000): Incorrect string value: '\xE5\xBC\xA0\xE4\xB8\x89' for column 'name' at row 1
mysql> insert into t_student_info values('2016010101','zhangsan','man','56323232','湖北省武汉市');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> insert into t_student_info values('2016010101','zhangsan','man','56323232','湖北省武汉市');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> insert into t_student_info values('2016010101','zhangsan','23','man','56323232','湖北省武汉市');
ERROR 1366 (HY000): Incorrect string value: '\xE6\xB9\x96\xE5\x8C\x97...' for column 'address' at row 1
mysql> insert into t_student_info values('2016010101','zhangsan','23','man','56323232','hubei');
Query OK, 1 row affected (0.00 sec)

mysql> select * from t_student_info;
+------------+----------+------+------+----------+---------+
| id         | name     | age  | sex  | qq       | address |
+------------+----------+------+------+----------+---------+
| 2016010101 | zhangsan |   23 | man  | 56323232 | hubei   |
+------------+----------+------+------+----------+---------+
1 row in set (0.00 sec)

mysql> insert into t_student_info values('2016010102','zhangnan','21','man','563232312','市');
ERROR 1366 (HY000): Incorrect string value: '\xE5\xB8\x82' for column 'address' at row 1
mysql> 

2、错误原因

(1)ERROR 1136 (21S01): Column count doesn't match value count at row 1

     这个错误是由于插入的列与表中的字段不对应,数据类型不匹配


(2)ERROR 1366 (HY000): Incorrect string value: '\xE5\xB8\x82' for column 'address' at row 1

     这个错误是由于MySQL不能识别中文,导致报错


3、解决办法

(1)对于错误一,比对字段的个数以及数据类型,保证一致

(2)对于错误二,修改MySQL编码格式