错误提示:Incorrect string value: ‘\xE7\xA8\x8B\xE5\xBA\x8F…’ for 【column】 ‘course’ at row 1
出现这个错误的原因是,数据库的编码格式为latin1 而我要将utf8的中文插入到数据库中。
一开始修改 修改数据库的编码
alter table score default character set utf8;
但是插入中文依然出现错误。
然后通过查看数据表编码
show create table score;
发现如下所示
![图片[1]-Mysql 插入中文错误-IT网络技术分享](https://zywi.cn/wp-content/uploads/2021/11/552d77765a0e-1024x352.jpg)
下面就是更改列的编码即可
alter table score change score score varchar(50) character utf8;
修改成功之后
![图片[2]-Mysql 插入中文错误-IT网络技术分享](https://zywi.cn/wp-content/uploads/2021/11/ef61fc2b6fa3-1024x293.jpg)
结果是列的编码已经修改成功
接下来插入utf8中文就没有问题了
![图片[3]-Mysql 插入中文错误-IT网络技术分享](https://zywi.cn/wp-content/uploads/2021/11/824e00194529.jpg)
THE END
暂无评论内容