mysql5.7执行sql语句报错:In aggregated query without GROUP BY, expression #1 of SELECT list contains nonagg

mysql5.7执行sql语句报错:In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'yunva_changke.u.user_id'; this is incompatible with sql_mode=only_full_group_by





1.方法1,需要重启mysql服务





编辑/etc/my.cnf文件,加入如下参数,重启mysql

sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"

mysql5.7执行sql语句报错:In aggregated query without GROUP BY, expression #1 of SELECT list contains nonagg



2.方法2,不需要重启mysql服务





可以看到模式为only_full_group_by

mysql>show variables like '%sql_mode';



mysql> show session variables like '%sql_mode%';

mysql> show global variables like '%sql_mode%';





使当前会话失效

mysql> set global sql_mode='';

mysql> set session sql_mode='';

上一篇:gulp 自动ftp至服务器时,处理开发 测试服务器地址问题


下一篇:java linux 项目经常无故被关闭 进程无故消息