解决mysql插入中文字符报错的问题ERROR 1366 (HY000): Incorrect string value: '\xE5\xB0\x8F\xE6\x98\x8E' for column 'name' at row 1

报错内容:

mysql> insert into person values (1,22,'小明');
ERROR 1366 (HY000): Incorrect string value: '\xE5\xB0\x8F\xE6\x98\x8E' for column 'name' at row 1

 

解决方法:

1、查看建表语句

 

2、表字符集修改,chartset为utf8

alter table person default character set utf8;

 

3、字段字符集修改

 alter table person change name name varchar(255) character set utf8;

 

 再次插入数据:

mysql> insert into person values (1,22,'小明');
Query OK, 1 row affected (0.01 sec)

执行成功。

 

posted @ 2019-02-12 15:29  蔚之蓝  阅读(13532)  评论(2编辑  收藏  举报