本地测试没有问题,部署到客户服务器之后报如下错误:

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中出现。 
查看sql_mode的语句如下:

select @@GLOBAL.sql_mode;
  • 1

可以使用sql语句暂时修改sql_mode:

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
  • 1

然而重启mysql数据库之后,ONLY_FULL_GROUP_BY又出现了,顺便写下重启数据库命令:

service mysqld stop
service mysqld start
  • 1
  • 2

所以需要修改mysql配置文件,通过手动添加sql_mode的方式强制指定不需要ONLY_FULL_GROUP_BY属性,my.cnf位于etc文件夹下,vim下光标移到最后,添加如下:

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

重启后问题解决。

mysql下this is incompatible with sql_mode=only_full_group_by解决方案的更多相关文章

  1. this is incompatible with sql_mode=only_full_group_by

    mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by - Jim_.NET - 博客园 http://www.c ...

  2. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: ..... this is incompatible with sql_mode=only_full_group_by

    一.异常信息 org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: com.mysq ...

  3. mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by

    在mysql 工具 搜索或者插入数据时报下面错误: ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause ...

  4. 5.7版本mysql查询报错:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:...this is incompatible with sql_mode=only_full_group_by

    先瞧下日志: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException ...

  5. mysql报错处理:incompatible with sql_mode=only_full_group_by

    问题: 服务报错:incompatible with sql_mode=only_full_group_by,如下图所示: 分析: NLY_FULL_GROUP_BY是MySQL提供的一个sql_mo ...

  6. 【Solution】MySQL 5.8 this is incompatible with sql_mode=only_full_group_by

    [42000][1055] Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colu ...

  7. mysql(5.7以上)查询报错:ORDER BY clause is not in GROUP BY..this is incompatible with sql_mode=only_full_group_by

    执行mysql命令查询时: select * from table_name错误信息如: [Err] 1055 - Expression #1 of ORDER BY clause is not in ...

  8. mysql报错this is incompatible with sql_mode=only_full_group_by

    1.报错信息 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP ...

  9. Mysql插入数据时,报错this is incompatible with sql_mode=only_full_group_by

    Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'inform ...

随机推荐

  1. uart测试代码

    #include <stdio.h> /*标准输入输出定义*/ #include <stdlib.h> /*标准函数库定义*/ #include <unistd.h> ...

  2. Java Collection API

    在 Java2中,有一套设计优良的接口和类组成了Java集合框架Collection,使程序员操作成批的数据或对象元素极为方便.这些接口和类有很多对抽象数据类型操作的API,而这是我们常用的且在数据结 ...

  3. 20145240《Java程序设计》第一周学习总结

    20145240 <Java程序设计>第一周学习总结 教材学习内容总结 第一周学习Java首先从最基本的下载.配置环境.了解基本人机命令行方式等基础知识,以及编写简单的"Hell ...

  4. UVA 10909 Lucky Number(树状数组+二分+YY)

    此题测试时预处理等了很久,结果470ms过了...... 题意:开始不怎么懂,结果发现是这个: 波兰裔美国数学家斯塔尼斯拉夫·乌拉姆(Stanislaw Ulam)在20世纪50年代中期开发出了另一种 ...

  5. 初探MyBatis之HelloWorld(一)

    官方地址:https://github.com/mybatis/mybatis-3 准备: 官方中文文档地址:http://www.mybatis.org/mybatis-3/zh/getting-s ...

  6. 从配置maven环境到maven项目的新建

    话不多说,直接入正题. 一.配置maven 环境 首先安装最新版支持javaee的eclipse.我这里下载的版本是eclipse-jee-mars-2-win32-x86_64的新版(我是2017年 ...

  7. ZC_知识点

    1. 在创建一个JNI动态库的工程时应该将工程的输出目标设置为动态连接库(Windows下为.dll,Unix-like系统下为.so,OS X下为.dylib) 2.类型对应关系 (Java与C/C ...

  8. ansible实现发布、回滚功能

    ansible的两篇博客,本来是打算合二为一的,发现只用一篇写,嗯,好鬼长.... 一向秉承简单为美的我于是忍痛割爱,一分为二了 ansible实现升级发布.回滚功能 1.应用场景 在实际生产环境中, ...

  9. DOM初体验(绑定事件,监听事件)

    JavaScript的组成: ECMAScript(js的基本语法).DOM(文档对象模型).BOM(浏览器对象模型) DOM的作用: 1. 找到页面上的元素 2. 增添.删除.修改页面上的元素 3. ...

  10. django 使用多说 评论系统

    效果图 方法:登录多说网站,创建站点.然后有下面的提示 ************************************************* 复制以下代码,并粘帖到您网页代码<bo ...