mysql报错this is incompatible with sql_mode=only_full_group_by解决方案
本地测试没有问题,部署到客户服务器之后报如下错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘testID’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
这个错误的原因是高版本mysql(客户服务器版本是5.7.18)默认的sql_mode包含ONLY_FULL_GROUP_BY,这个属性保证了select到的列都在group by中出现。
1.查看sql_mode的语句如下:
select @@GLOBAL.sql_mode;
2.可以使用sql语句暂时修改sql_mode:
select version(), @@sql_mode;SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
3.然而重启mysql数据库之后,ONLY_FULL_GROUP_BY又出现了,顺便写下重启数据库命令:
service mysqld stop
service mysqld start
4.修改mysql配置文件my.ini (linux系统修改my.cnf),把 ONLY_FULL_GROUP_BY 从sql_mode中去掉
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
如果没有以上配置就添加到[mysqld]中,注意:需要重启mysql服务生效。
- MySql版本问题sql_mode=only_full_group_by的完美解决方案
- 5分钟学会MySQL-this is incompatible with sql_mode=only_full_group_by错误解决方案
- 2分钟学会MySQL-"this is incompatible withsql_mode=only_full_group_by"错误解决方案
- MySql版本问题sql_mode=only_full_group_by解决方案
- mysql下this is incompatible with sql_mode=only_full_group_by解决方案
- mysql下this is incompatible with sql_mode=only_full_group_by解决方案
- MySql版本问题sql_mode=only_full_group_by的完美解决方案
- mysql sql_mode=only_full_group_by 解决方案
- Mysql5.7 only_full_group_by以及其他关于sql_mode原因报错详细解决方案
- MySql8报错:this is incompatible with sql_mode=only_full_group_by
- MySQL Error this is incompatible with sql_mode=only_full_group_by
- mysql 1055错误的解决办法 【MYSQL5.7版本sql_mode=only_full_group_by问题】
- this is incompatible with sql_mode=only_full_group_by
- mysql [Err] 1055 this is incompatible with sql_mode=only_full_group_by
- mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by
- 解决:this is incompatible with sql_mode=only_full_group_by
- MYSQL: this is incompatible with sql_mode=only_full_group_by的解决方法
- MySQL 报错:5.7版本sql_mode=only_full_group_by问题
- MySQL 5.7.9版本sql_mode=only_full_group_by问题
- mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by