Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
程序员文章站
2022-03-23 17:09:18
...
话不多说,直接解决。
此方法是永久解决,如需临时解决,直接看文章结尾即可。
第一步,使用mysql查询
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
第二步,将前面 ‘ONLY_FULL_GROUP_BY’ 去除,留下后一段
STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
第三步,打开mysql配置文件 /etc/mysql/my.cnf
vi /etc/mysql/my.cnf
第四步,将sql_mode复制到配置文件[mysqld]下方,sql_mode的值就是上面第二步得到的,这个很重要,随便复制的可能导致MySQL无法打开。
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
第六步,重启mysql
service mysql restart
完成
临时解决
mysql> select @@global.sql_mode
# result: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
#去除 ‘ONLY_FULL_GROUP_BY’
mysql> set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
mysql> set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
上一篇: php获取文件扩展名的5种方法是什么
下一篇: 怎么查看nodejs安装的模块
推荐阅读
-
解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
-
解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo.
-
mysql从5.6升级到5.7后出现 Expression #1 of ORDER BY clause is not in SELECT list,this is incompatible with DISTINCT
-
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate
-
ERROR 1055 (42000): Expression #3 of SELECT list is not in GROUP BY clause ... 的错误
-
报错 1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated
-
1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains解决
-
idea报错 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre
-
linux上,mysql使用聚合函数group by 时报错:SELECT list is not in GROUP BY clause and contains nonaggre的问题
-
解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated