SQLSTATE[HY000]: General error: 1366 Incorrect string value
在Laravel项目的 storages/logs/Laravel.log看到的错误信息片段:
SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF0\x9F\x91\x8B\xF0\x9F...' for column 'name' at row 1
出错原因:检查数据库此字段的字符集与整理字符集是否与SQL语句传递数据的字符集相同;不相同则会引发MySQL1366错误。
解决方法:
#1.检查数据表所有字段的状态
mysql> SHOW FULL COLUMNS FROM tdb_goods;
#2.发现collatioin项非utf8,需要进行修改,使用如下的语句
mysql> alter table tdb_goods change goods_name name varchar(100) character set utf8 collate utf8_unicode_ci not null default '';
#3.检查数据表所有字段的状态
mysql> SHOW FULL COLUMNS FROM tdb_goods;
mysql> select * from tdb_goods\g
mysql语句的\g等同于;,\G:将查询到的横向表格纵向输出,方便阅读
未进行修改my.cnf,下面内容可跳过。记录自己的了解和尝试
参考别人的博文,说是 mysql的配置sql-model不正确导致的,需要将 my.cnf中的sql-model中的STRICT_TRANS_TABLES删除
STRICT_TRANS_TABLES(存储引擎启用严格模式,非法数据值被拒绝)
我的mysql配置文件是在/etc/my.cnf
sudo cp /etc/my.cnf /etc/my.cnf_bak190628
sudo vim /etc/my.cnf
将
[mysqld]
sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
改为
[mysqld]
sql_mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
删除了STRICT_TRANS_TABLES,然后重启 mysql
不修改 my.cnf (在不清楚my.cnf存放的位置时可使用的,但是在mysql服务重启之后,这个设置会失效)
show variables like 'sql_mode';
set global sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
References
- SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'xxx' at row 1
- mysql出现ERROR 1366 (HY000):的解决办法
- mysql中\G和\g的作用
- MySQL中\g和\G的作用
- How do I find the MySQL my.cnf location
SQLSTATE[HY000]: General error: 1366 Incorrect string value的更多相关文章
- SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xF0\x9F\x90\xA3\xF0\x9F...' for column
在做微信公众号保存用户数据时出现这种错误,一直不知道是哪里的原因,后来发现那个用户昵称带着一只兔子表情,由于数据库编码限制不能保存数据,所有需要先编码, 用PHP的函数就是base64_encode, ...
- mysql General error: 1366 Incorrect string value: '\xF0\x9F\x91\x8D\xF0\x9F...' for column 'dianpumiaoshu' at row 1 解决方法
mysql General error: 1366 Incorrect string value: '\xF0\x9F\x91\x8D\xF0\x9F...' for column 'dianpumi ...
- string(81) "SQLSTATE[HY000]: General error: 1364 Field 'content' doesn't have a default value"
mysql版本是5.7.26,在插入数据时报错: string(81) "SQLSTATE[HY000]: General error: 1364 Field 'content' doesn ...
- legend2---数据字段没有默认值错误:SQLSTATE[HY000]: General error: 1364 Field 'h_21_injury_limit' doesn't have a default value
legend2---数据字段没有默认值错误:SQLSTATE[HY000]: General error: 1364 Field 'h_21_injury_limit' doesn't have a ...
- SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (utf8_general_ci,IMPLICIT) and (gb2312_chinese_ci,COERCIBLE) for operation '='
在操作MySQL数据库时,报“ error code [1267]; Illegal mix of collations (gbk_chinese_ci,IMPLICIT) and (utf8_gen ...
- SQLSTATE[HY000]: General error: 1030 Got error 28 from storage engine
今天上课程化平台考试,输入平台网址突然报这个错误 可以先df -h 发现/tmp文件使用满了 ,清理下不需要的临时文件即可
- MySQL报错: SQLSTATE[HY000]: General error: 1030 Got error 28 from storage engine
执行命令:df -h [root@iZ25z6qcmrhZ ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/xvda1 40G 38G ...
- SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction 解决方法
SHOW FULL PROCESSLIST; KILL 263071
- corresponding SQLSTATE values general error
http://dev.mysql.com/doc/refman/5.7/en/error-messages-server.html B.3 Server Error Codes and Message ...
随机推荐
- hbase启动的时候报:cat: /home/hadoop/hbase-0.94.6-cdh4.5.0/target/cached_classpath.txt: 没有那个文件或目录
启动hbase的时候: -cdh4.5.0/bin$ hbase shell cat: /home/hadoop/hbase--cdh4.5.0/target/cached_classpath.txt ...
- CSS:Stacking Context
通常情况下,HTML页面可以被认为是二维的,因为文本,图像和其他元素被排列在页面上而不重叠.在这种情况下,只有一个渲染进程,所有元素都知道其他元素所占用的空间.z-index属性可让你在渲染内容时调整 ...
- 长度为x的本质不同的串的出现次数 SPOJ - NSUBSTR 后缀自动机简单应用
题意: 长度为x的本质不同的串的出现次数 题解: 先处理出每一个节点所对应的子串出现的次数 然后取max就好了 #include <set> #include <map> #i ...
- 2018年第九届蓝桥杯B组第四题:摔手机题解
摔手机 摔手机 动态规划 在蓝桥杯的时候遇到一次 当时没有做对 看了题解也没明白 如今再次遇到这个类似的题目 于是拿出来补补吧 摔手机题目如下: 星球的居民脾气不太好,但好在他们生气的时候唯一的 ...
- wireshark抓包总结
过滤规则: ip.src == 源地址 and http(协议)
- EF批量添加
1.首先,打开工具——NuGet包管理器——管理解决方案的NoGet程序包——搜索Z.EntityFramework.Extensions 点击安装!!! codefirst定义一个实体,用EF的方法 ...
- Batch - %~dp0 modifiers
%~dp0 简易解释 The variable %0 in a batch script is set to the name of the executing batch file. The ~dp ...
- JMM 内存模型 与 volatile 关键字
内存模型 线程之间的共享变量存储在主内存(main memory)中,每个线程都有一个私有的本地内存(local memory). 本地内存中存储了该线程以读/写共享变量的副本. 不同线程之间无法相互 ...
- Kotlin Download
{ https://github.com/JetBrains/kotlin/releases/tag/v1.3.50 }
- JAVA错误:Exception in thread "main" java.lang.NullPointerException
JAVA错误:Exception in thread "main" java.lang.NullPointerException例如: Exception in thread &q ...