执行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
解决办法:
把 sql_mode中的 only_full_group_by 去掉即可。即修改 my.cnf 文件的 sql_mode参数:
1.查找 my.cnf 文件: find / -name my.cnf 或者 whereis my.cnf
2.获取 sql_mode字段内容: SELECT @@sql_mode;
3.去掉 sql_mode结果中的 only_full_group_by属性。
4.编辑 my.cnf: vim /etc/my.cnf 将上一步骤的 sql_mode 字段内容添加至 my.cnf
保存。
5.重启mysql服务: service mysqld restart。
再次执行发现已无报错。
具体mysql5.7版本的sql_mode参数参考如下:
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION