Mysql 插入中文错误insert into book values(,'金瓶梅','好书!!!') Error Code: 1366. Incorrect string value: '\x......

出现这个错误的原因是,数据库的编码格式为latin1 而我要将utf8的中文插入到数据库中。

一开始修改 修改数据库的编码

alter table score default character set utf8;

但是插入中文依然出现错误。

查看你的mysql数据库的编码设置

show variables like 'character%';

最后修改表的列的字符集
例:修改book表的category列的字符集

alter table book change category category varchar(50) character set utf8 collate utf8_unicode_ci not null default '';

猜你喜欢

转载自blog.csdn.net/weixin_34253539/article/details/87318090
今日推荐