今天我们来说下 mysql8 关于only_full_group_by的问题,相信每个人在使用group by 函数时会突然跳出一个报错信息:
ERROR 1055 (42000): Expression #7 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'postscan.verifyDelayLog.auditor' which is not functionally dependent on columns in GROUP BY clause; this is incompatible withsql_mode=only_full_group_by
在mysql8.0以上的版本中,对于 group by 的这种聚合操作,如果在select 中的列,没有在group by 中出现,那么这个SQL是不合法的,因为列不在group by的从句中,所以对于设置了这个mode的数据库,在使用group by 的时候,就要用MAX(),SUM(),ANT_VALUE()的这种聚合函数,才能完成GROUP BY 的聚合操作,那么话说回来了,如何关闭呢?
经过我们一番百度之后,获取的结果是关于 only_full_group_by ,但是按照教程所说,只要修改了my.cnf,
【
在my.cnf添加如下配置
[mysqld]
sql_mode='NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREAT