mysql插入中文出错“ERROR 1366 (HY000): Incorrect string value: ‘\xE5\xBC\xA0\xE4\xB8\x89‘ for column ‘name“

small_Sun

关注

阅读 69

2022-11-16


在linux系统在向mysql中插入中文数据的时候会报错误

ERROR 1366 (HY000): Incorrect string value: '\xE5\xBC\xA0\xE4\xB8\x89' for column 'name' at row 1

这主要是因为编码造成的, 我们修改一下编码即可

第一种方法:

只修改这个表的编码格式:

> alter table user convert to charset utf8;

如下图:

mysql插入中文出错“ERROR 1366 (HY000): Incorrect string value: ‘\xE5\xBC\xA0\xE4\xB8\x89‘ for column ‘name“_linux系统

第二种方法:

修改mysql默认的编码格式

我们先查看数据库默认的编码格式:

> show  variables  like '%char%';

mysql插入中文出错“ERROR 1366 (HY000): Incorrect string value: ‘\xE5\xBC\xA0\xE4\xB8\x89‘ for column ‘name“_编码_02

可以看到默认是拉丁格式(latin1)

精彩评论(0)

0 0 举报