已解决SELECT list is not in GROUP BY clause and contains nonaggregated column
Posted nanke_yh
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了已解决SELECT list is not in GROUP BY clause and contains nonaggregated column相关的知识,希望对你有一定的参考价值。
一、原因
mysql5.7.5后only_full_group_by成为sql_mode的默认选项之一,这可能导致一些sql语句失效。
二、解决办法
1、命令行打开mysql.cnf,默认路径为/etc/mysql/conf.d/mysql.cnf,如果找不到可以使用whereis进行查询
sudo vim /etc/mysql/conf.d/mysql.cnf
按i 进行编辑
2、滚动到文件底部复制并粘贴以下代码
[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
按Esc退出编辑状态,左下角输入 :wq 即可保存并退出
3、保存退出后重启mysql
sudo service mysql restart
以上是关于已解决SELECT list is not in GROUP BY clause and contains nonaggregated column的主要内容,如果未能解决你的问题,请参考以下文章
Column '表名.某列名' is invalid in the select list because it is not contained in either an aggregate f
linux下order by 报出ORDER BY clause is not in SELECT list
MySQL出现“SELECT list is not in GROUP BY clause and contains xxx”错误提示
Mysql--Cause: java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY
mysql报错:Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre
#1055 - Expression of SELECT list is not in GROUP BY clause and contains nonaggregated column this i