mysql8.0在用group by分组报错ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY

在开发环境数据库用的5.7版本的,sql中写了group by分组,然后报错:ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'spider_rule.link_parameter.id' which is not functionally dependent on columns in GROUP BY

问题原因:sql_model=only_full_group_by限制了,导致在以往MYSQL版本中能正常查询的SQL,在5.7后面的版本不能用了

解决办法:在mysql的安装路径下的my.cnf文件中的[mysqld]下面加下面配置sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

正在加载评论...