如题。MySQL5.7每次执行Sql语句都会出现
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
虽然不影响,但是是什么原因呢
在MySQL5.7之后,sql_mode中默认存在ONLY_FULL_GROUP_BY,SQL语句未通过ONLY_FULL_GROUP_BY语义检查所以报错。
ONLY_FULL_GROUP_BY要求select语句中查询出来的列必须是明确的
完美解决方案是:
修改sql_model全局配值去掉sql_model中的ONLY_FULL_GROUP_BY
show variables like “sql_mode”;
set sql_mode=’’;
set @@global.sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION’
ps:关闭会话重新打开就不报错了,mysql服务重启会失效
如想彻底解决需求 修改配置文件。。
OK!