linux中解决mysql的 this is incompatible with sql_mode=only_full_group_by

2018/04/01

linux中解决mysql的 this is incompatible with sql_mode=only_full_group_by

好吧,换了服务器问题还挺多的。

中午的时候服务器抛了一个异常:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column
 'blog.log.brower' which is not functionally dependent on columns in GROUP BY clause; 
 this is incompatible with sql_mode=only_full_group_by

就按网上的方法:

set @@GLOBAL.sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,
ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

起作用了,但晚上改服务器字符集重启了一下mysql,又给还原了,这不是办法。

于是就在配置文件(/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

问题解决!

Post Directory