美文网首页
Mysql 插入中文错误insert into book val

Mysql 插入中文错误insert into book val

作者: WSGNSLog | 来源:发表于2019-01-23 19:01 被阅读8次

出现这个错误的原因是,数据库的编码格式为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 '';

相关文章

网友评论

      本文标题:Mysql 插入中文错误insert into book val

      本文链接:https://www.haomeiwen.com/subject/gdusjqtx.html