TP5查询数据时报错Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY解决办法

报错信息太长了, 标题写不下..
完整报错信息:

Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'x.xxx' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

我使用的是Windows系统, 环境是小皮面板

错误原因:

这个错误发生在mysql 5.7 版本及以上版本会出现的问题, 在mysql5.7版本默认的sql配置是:

sql_mode="ONLY_FULL_GROUP_BY"

这个配置严格执行了”SQL92标准”, 很多从5.6升级到5.7时,为了语法兼容, 大部分都会选择调整sql_mod, 使其保持跟5.6一致, 为了尽量兼容程序.

解决办法:

找到数据库配置文件windows中my.ini文件或linux中的my.cnf文件,在mysqld中增加sql_mode=

[mysqld]
sql_mode=

保存后重启MySQL即可.

记录一下.
-End-

风影OvO

风影OvO, 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA 4.0协议进行授权 | 转载请注明原文链接

1 Comment

留下你的评论

*评论支持代码高亮<pre class="prettyprint linenums">代码</pre>

相关推荐