问题记录【Data truncation: Incorrect string value: '\xE4\xB8\x83\xE6\x98\x9F...'】
2020-06-28 05:08
453 查看
本地正常,部署到服务器运行的时后,给数据库插入中文数据时会报错
第一步
首先在 etc/my.cnf修改字符编码为utf8mb4
[root@iZ2zebh41nm7vqxyy35hiqZ jar]# cat /etc/my.cnf # # This group is read both both by the client and the server # use it for options that affect everything # [client-server] [mysqld] init_connect='set collation_connection = utf8mb4_general_ci' init_connect='set collation_database=utf8mb4_general_ci' init_connect='set names utf8mb4' init_connect='set character_set_connection=utf8mb4' character-set-server=utf8mb4 collation-server=utf8mb4_general_ci skip-character-set-client-handshake # # include all files from the config directory # !includedir /etc/my.cnf.d [root@iZ2zebh41nm7vqxyy35hiqZ jar]#
结果还是报错,有点懵
第二步
更改数据库编码:
ALTER DATABASE 数据库名 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
更改表编码:
ALTER TABLE 表名 CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
更改列编码:
ALTER TABLE 表面 CHANGE 列名 列名 VARCHAR( 36 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL
因为没多少数据,我直接删除整个表
只更新了数据库编码
最后:问题解决
相关文章推荐
- 关于Data truncation: Incorrect string value: '' for column 问题的解决办法
- MySQL错误:插入表记录的时候出现“Incorrect string value”问题
- 通俗易懂地解决中文乱码问题(2) --- 分析解决Mysql插入移动端表情符报错 ‘incorrect string value: '\xF0...
- 完美解决某些字符插入到mysql数据库出现incorrect string value的问题
- 解决Mysql插入中文乱码问题:Incorrect string value: ‘\xA8D\xA8D\xBA\xE1…’ for column
- 解决emoji表情的数据库存取问题:Cause: java.sql.SQLException: Incorrect string value
- Data truncation: Truncated incorrect DOUBLE value: 'N900'问题解决
- MySQL 更新中国列:1366 Incorrect string value 问题解决了
- mysql中Incorrect string value乱码问题解决方案
- 在navicat for mysql中解决mysql数据库不能插入中文问题Incorrect string value: '\xE6\x9D\x8E\xE5\x8B\x87' for column '
- MySQL字符编码问题,Incorrect string value
- Ubuntu下Mysql 5.7中文插入失败的问题,Incorrect string value
- MySQL字符编码问题,Incorrect string value
- mysql问题 Incorrect string value:"/ / / / /"for column'trurname' at row 1
- 问题:Incorrect string value: '\xE5\xAE\x89\xE5\x8D\x93...' for column 'use_device' at row 1
- mysql中[Err] 1366 - Incorrect string value: '\xE5\x8D\x问题
- 【问题解决】MySQL5.5 向MySQL数据库中插入汉字时,提示:Incorrect string value: '\Xe7\x8E...' for column 'XXX' at row 1
- jeesite导入数据库错误:java.sql.SQLException: Incorrect string value: '\xE4\xB8\xAD\xE5\x9B\xBD' for column 'name' at row 1问题解决
- MySQL 更新中文列:1366 Incorrect string value 问题解决
- 解决在MySQL中插入中文出现"Incorrect string value"的问题