this is incompatible with sql_mode=only_full_group_by

项目换了个数据库报错:html

; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'kjwl.a.description' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_bymysql

 

主要由于某些 sql group by 语句写得不规范,且数据库设置语法规则比较严格的时候会报错。若是不想改 sql 语句则要改 mysql 的设置:sql

sql_mode 中去掉 only_full_group_by 项。数据库

能够在 mysql 命令行下输入 SELECT @@sql_mode; 查看当前 sql_mode 有哪些设置。this

 

而后能够执行:命令行

 

set @@GLOBAL.sql_mode='';htm

set sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';blog

即重设此值。但这还有一个问题,就是重启 mysql 后设置会被还原。因此上面设置要放到 mysql 的配置文件中,默认是 /etc/my.cnfip

在 [mysqld] 项下增长(只要里面没有only_full_group_by 就好了)get

 

# to solve problem: this is incompatible with sql_mode=only_full_group_by

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

 

 

网上还有说增长的项写成像执行命令的语句同样,但我用本身的版本试则启动失败,用上面那种方式就能够。

参考(有改动):http://www.cnblogs.com/jim2016/p/6322703.html

相关文章
相关标签/搜索