centos7环境的mysql5.7执行下group语句
select tb1.name,sum(1) as num
from table_1 tb1
GROUP BY tb1.name
错误提示:SELECT list is not in GROUP BY clause and contains nonaggregated column ‘***’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
解决方法
//编辑my.cnf文件
vim /etc/my.cnf
//在[mysqld]下面添加一行,图下图
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION