[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colum

官方说法

https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html

一、查询mysql 相关mode

1、show variables like '%sql_mode%'命令

2、select version(), @@sql_mode 命令

查询出的数据如下图:

[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colum_第1张图片

[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colum_第2张图片

二、通过select version(), @@sql_mode 命令查询,发现 里面 有  ONLY_FULL_GROUP_BY , 将其删除掉,

再把sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION',复制到/etc/my.cnf文件中,如下图:

[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colum_第3张图片

[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colum_第4张图片

三、然后重启mysql

service mysqld stop       停止mysql服务命令

service mysqld start      启动mysql服务命令

[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colum_第5张图片

你可能感兴趣的:(mysql)