mac电脑新安装的mysql8.0.29版本的mysql;
今天第一次执行sql:
SELECT a,b,c FROM test_fidx WHERE a='4097aa' GROUP BY b LIMIT 10;
报错如下:
ERROR 1055 (42000): Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'study.test_fidx.c' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by;
原因大致是:sql_model=only_full_group_by限制了,导致在以往MYSQL版本中能正常查询的SQL,在8.0不能用了;
1、解决办法1(适用于mac系统中):
vim /opt/homebrew/etc/my.cnf
打开文件后新增如下代码:
[mysqld]
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
保存退出就可以了;
然后从这里进入mysql
配置路径
然后重启即可;
在进入mysql 去试一下效果就可以了
2、linux系统同理:去修改my.cnf配置然后重新启动就可以。