mysql 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column

1。问题描述:

新安装得mysql 执行代码时出意异常:

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

2.原因分析:MySQL 5.7.5及以上功能依赖检测功能。如果启用了ONLY_FULL_GROUP_BY SQL模式(默认情况下),MySQL将拒绝选择列表,HAVING条件或ORDER BY列表的查询引用在GROUP BY子句中既未命名的非集合列,也不在功能上依赖于它们。

                     MySQL5.7.5之下没有检测到功能依赖关系,默认情况下不启用ONLY_FULL_GROUP_BY。

3.解决方案:

  临时性解决方案:

    执行:set sql_mode =(select replace(@@sql_mode,'ONLY_FULL_GROUP_BY','')); 

  永久性解决方案:

    查找mysql配置文件位置:find / -name my.cnf

    添加配置项:”sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION“    到配置文件

    重启MySQL:systemctl restart mysqld.service

    

素材巴巴码巴巴

posted @ 2020-09-02 12:05  步步丶惊云  阅读(336)  评论(0编辑  收藏  举报