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

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. 【[NOI2011]智能车比赛】(建图+spfa+坑爹精度)

    过了这题我就想说一声艹,跟这个题死磕了将近6个小时,终于是把这个题死磕出来了.首先看到这个题的第一反应,和当初做过的一个房间最短路比较相似,然后考虑像那个题那样建边,然后跑最短路.(具体建边方法请参考 ...

  2. 泛型学习第一天:List与IList的区别 (二)

    原文: 探讨Ilist<>与List<> 首先要了解一点的是关于接口的基础知识: 接口不能直接实例化但是接口派生出来的抽象类可以实例化所有派生出来的抽象类都可以强制转换成接口的 ...

  3. HDFS-文件读取API

    package com.zhen.hdfs; import java.io.IOException; import java.io.InputStream; import java.net.URI; ...

  4. socket io 记得flush

    public class Client { public static void main(String args[]) throws Exception { //为了简单起见,所有的异常都直接往外抛 ...

  5. MySql 创建/删除数据库

    C:\Users\Mr.Black>mysql -u root -pEnter password: ****Welcome to the MySQL monitor.  Commands end ...

  6. nova notification

    1 compute.instance.update类型的消息 需要配置notify_on_state_change参数,可以为空,或者vm_state,或者vm_and_task_state, 当虚拟 ...

  7. 开发者必备,超实用的PHP代码片段!

    此前,研发频道曾发布<直接拿来用,10个PHP代码片段>,得到了网友们的一致好评.本文,笔者将继续分享九个超级有用的PHP代码片段.当你在开发网站.应用或者博客时,利用这些代码能为你节省大 ...

  8. 冒泡排序的PHP实现 Bubble Sort

    冒泡排序Bubble Sort的PHP实现.代码中函数说明: out_arr,用于将数组输出成一个字符串,以便查看 bubblesort,第一种实现方案,从后往前依次选出需要的值,这里是较大的 bub ...

  9. nginx基本参数详解

    运行用户 user nobody; 启动进程,通常设置成和cpu的数量相等 worker_processes 1; 全局错误日志及PID文件 error_log logs/error.log; err ...

  10. 使用Spring MVC表单标(转)

    概述     在低版本的Spring中,你必须通过JSTL或<spring:bind>将表单对象绑定到HTML表单页面中,对于习惯了Struts表单标签的开发者来说,Spring MVC的 ...