码迷,mamicode.com
首页 > 数据库 > 详细

Mysql only_full_group_by 引起的错误

时间:2019-04-20 13:09:45      阅读:354      评论:0      收藏:0      [点我收藏+]

标签:group   配置   _for   sub   string   mysq   erro   stat   err   

SQLSTATE[42000]: Syntax error or access violation:
1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column -._task.id which is not functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by

#查询当前的模式设置

SELECT @@sql_mode;

ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

#设置mode[需要root有权限]

set GLOBAL sql_mode =‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION ‘;

#直接修改配置文件,然后重启

在my.cnf 里面设置
sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘
在sql_mode 中去掉only_full_group_by 

Mysql only_full_group_by 引起的错误

标签:group   配置   _for   sub   string   mysq   erro   stat   err   

原文地址:https://www.cnblogs.com/yamboo/p/10740450.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!