mysql5.7中关于sql_mode=only_full_group_by问题

问题

项目启动报错,

1
which is not functionally dependent on columns in GROUP BY clause; this is incompatible withsql_mode=only_full_group_by

数据库查询select @@sql_mode出现ONLY_FULL_GROUP_BY字段

解决

在my.cnf中[mysqld]下添加

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

查找my.cnf文件的路径

mysql --help|grep my.cnf

显示

1
2
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

可以得出结论,mysql配置文件依次会从/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf中去寻找配置文件,直到找到my.cnf

赏个🍗吧
0%