Mysql5.7.11中groupby的sql语句引起的异常

遇到了异常:

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'a.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

解决方法

1,运行命令

SET GLOBAL sql_mode='';


但是这样重启后就失效了,因为set global的配置是放在内存中的。


2,设置mysql的配置文件,在/etc/my.cnf里



ps:这个设置是mysql5.7.5版本之后默认加入的,在mysql5.7.11里show global variables like "sql_mode",得到如下的结果:

Mysql5.7.11中groupby的sql语句引起的异常_第1张图片

(这个系统显示貌似有点问题)




你可能感兴趣的:(编程)