解决[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated
作者:mmseoamin日期:2024-02-04

一、问题描述

在使用MySQL查询时报了一个没有见过的错误:

[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

二、解决方法

1、在windows环境下,MySQL的安装路径中有一个my.ini文件,在里面加入以下内容

(一定要在[mysqld] 下面添加)

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

2、在虚拟机环境下的/etc/my.cnf配置文件的[mysqld] 下添加以下内容:

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

然后在MySQL的bin目录下输入service mysqld restart重启MySQL即可