mysql5.7 this is incompatible with sql_mode=only_full_group_by错误
解决办法:
https://blog.csdn.net/qq_42175986/article/details/82384160
前言:
一、原理层面
这个错误发生在mysql 5.7 版本及以上版本会出现的问题:
mysql 5.7版本默认的sql配置是:sql_mode="ONLY_FULL_GROUP_BY",这个配置严格执行了"SQL92标准"。
很多从5.6升级到5.7时,为了语法兼容,大部分都会选择调整sql_mode,使其保持跟5.6一致,为了尽量兼容程序。
二、sql层面
在sql执行时,出现该原因:
简单来说就是:输出的结果是叫target list,就是select后面跟着的字段,还有一个地方group by column,就是
group by后面跟着的字段。由于开启了ONLY_FULL_GROUP_BY的设置,所以如果一个字段没有在target list
和group by字段中同时出现,或者是聚合函数的值的话,那么这条sql查询是被mysql认为非法的,会报错误。
一、查看sql_mode的语句如下
select @@GLOBAL.sql_mode;
二、解决方案-(推荐解决方案二)
①解决方案一: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
问题:
重启mysql数据库服务之后,ONLY_FULL_GROUP_BY还会出现。
②解决方案二:完美解决方案。
需修改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
重启mysql服务,顺利解决。
---------------------
作者:猿医生
来源:CSDN
原文:https://blog.csdn.net/qq_42175986/article/details/82384160
版权声明:本文为博主原创文章,转载请附上博文链接!
重启mysql
Debian / Ubuntu Linux
1.启动:/etc/init.d/mysql start
2.停止:/etc/init.d/mysql stop
3.重启:/etc/init.d/mysql restart
mysql5.7 this is incompatible with sql_mode=only_full_group_by错误的更多相关文章
- mysql 查询出现 "this is incompatible with sql_mode=only_full_group_by"错误解决方案,以及个人rpm方式重装所遇到的问题备份
一.错误说明 这个错误发生在mysql 5.7 版本及以上版本会出现的问题: mysql .7版本默认的sql配置是:sql_mode="ONLY_FULL_GR ...
- 最近升级mysql5.7出现下面问题,ORDER BY clause is not in GROUP BY..this is incompatible with sql_mode=only_full_group_by
执行sql: SELECT * FROM `user_link` WHERE `group_id` IN ('78', '79') GROUP BY `link_id` 报错: SQLSTATE[42 ...
- mysql5.7 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 cla ...
- 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 ...
- sql mode 问题及解决 错误代码:1055 this is incompatible with sql_mode=only_full_group_by
数据库升级到5.7.21后,一个正常的分组后按日期排序,并返回数据的语句开始报错: 语句如下: SELECT id,title,add_time FROM `message` GROUP BY add ...
- 【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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- Expression Blend实例中文教程(11) - 视觉管理器快速入门Visual State Manager(VSM)
Expression Blend实例中文教程(11) - 视觉管理器快速入门Visual State Manager(V 时间:2010-04-12 16:06来源:SilverlightChina. ...
- uoj 30 tourists
题目大意: 一个无向图 每个点有权值 支持两个操作 1 修改某个点的权值 2 查询a-b所有简单路径的点上的最小值 思路: 可以把图变成圆方树 然后树链剖分 维护 对于每个方点使用可删堆维护 #inc ...
- EF通过反射追踪修改记录.适合记录变更系统
private static void IsUpdate<T>(T old, T current, string id) { Model.PerFileHistory history = ...
- C# 混淆 反编译
.net破解一(反编译,反混淆-剥壳) http://www.cnblogs.com/jio92/p/de4dot.html C#学习系列-String与string的区别 http://www.cn ...
- java.util.Optional
public class OptionalDemo { public static void main(String[] args) { //创建Optional实例,也可以通过方法返回值得到. Op ...
- PCB Redis的安装使用
记录一下Redis的安装与基本使用 一.Redis简介 Redis(REmote DIctionary Server)远程字典服务器,免费开源,是一个高性能的(Key/Value)分布式内存数据库.其 ...
- HDU1452:Happy 2004(积性函数)(因子和)
题意 给出\(x\),求\(2004^x\)的所有因子和 分析 \(2004=2*2*3*167\) 则\(2004^x\)=\(2^{2x}*3^x*167^x\) s[\(2004^x\)]=s[ ...
- Python Flask 实现移动端应用接口(API)
引言 目前,Web 应用已形成一种趋势:业务逻辑被越来越多地移到客户端,逐渐完善为一种称为富互联网应用(RIA,rich Internet application)的架构.在 RIA 中,服务器的主要 ...
- python常用的装饰器
一.为程序添加时间类的装饰器二.验证用户是否等陆 #.为函数添加统计时间的装饰器: import time def timeer(func): def inner(): starttime=time. ...
- python ftp小程序练习
作业要求: 开发一个支持多用户在线的FTP程序 要求: 1.用户加密认证 2.允许同时多用户登陆 3.每个用户都有自己的家目录,并且只能访问自己的家目录 4.对用户进行磁盘配额,每个用户的可用空间不同 ...