错误信息:
1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘cms.t00_user.id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
查询mysql版本:
select version()
错误原因:
百度了一下,原因是mysql5.7以上默认开启了only_full_group_by 模式
查询目前使用的sql_mode:
select @@sql_mode
处理方式:
临时处理:去除 ONLY_FULL_GROUP_BY 重启后失效
SET sql_mode =‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION’;
永久处理:
Linux下修改mysql的my.cnf
Window下修改mysql的my.ini
在[mysqld]下面增加
#关闭only_full_group_by
sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
重启mysql