The error is as follows:
Expression #2 of SELECT list is not in GROUP BY clause and contains
nonaggregated column ‘sss.month_id’ which is not functionally
dependent on columns in GROUP BY clause; this is incompatible with
sql_mode=only_full_group_by
Baidu has been working for a long time, and many bloggers ask to modify the mysql configuration file, but after the windows self-test found that it cannot solve the problem, and even causes the problem that mysql cannot be started.
First of all, we need to know the reason for this problem:
MySQL 5.7.5 and above functions depend on the detection function. If the ONLY_FULL_GROUP_BY
SQL mode is enabled (by default), MySQL will reject select lists, HAVING conditions, or ORDER BY lists that refer to non-aggregate columns that are neither named in the GROUP BY clause, nor are they functionally dependent on them (5.7 Before .5, MySQL did not detect functional dependencies, and ONLY_FULL_GROUP_BY was disabled by default.
The solution I used is as follows:
- Open Navicat and use sql query
select @@global.sql_mode;
查询结果为: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
- Remove the first ONLY_FULL_GROUP_BY and reset it
set @@global.sql_mode = ‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION’;
The problem can be solved in two simple steps