2021-05-21
mysql 联表查询出错为: only_full_group_by

在mysql8.x版本以上
联表查询出现了以下错误

1
2
3
1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
column 'db_instagram.VisitRecord.id' which is not functionally dependent on columns in
GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

这时候可以去 my.cnf文件中找到

1
2
3
my.cnf文件 存在位置
/etc/my.cnf
/etc/mysql/my.cnf
1
[mysqld]

设置

1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

然后保存

重启mysql 服务就可以了

1
systemctl restart mysqld
Read More