报错提示:
Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘sss.month_id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
问题解决步骤:
- select @@sql_mode; 查看sql_mode的值.会发现带有:only_full_group_by。
- 重新配置:
set session sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION’;- 如果还是无效,修改配置文件:找到mysqld.cnf配置文件,内容如下:
在里面添加一句:sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
注: docker容器中修改配置文件方法参考:
- 在宿主机中创建一个相同的文件,
- 将宿主机的文件复制到容器中:docker cp 宿主机文件的目录/mysqld.cnf 容器名称:/容器内文件目录。如:docker cp /etc/my.cnf.d/mysqld.cnf mysql:/etc/mysql/mysql.conf.d/
相关设置:
set global sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION’;