今天迁移django数据库的时候,跑程序的时候出现这样的错误:

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.
PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

没遇到过这样的问题,所以我把它记录下来,免得以后再次遇到。

先直接上解决办法吧,原理分析在后面,愿意看就看,不愿意这有解决办法,绝对管用。

""修改sql_mode的值,去掉ONLY_FULL_GROUP_BY""

进入你的mysql:

mysql -uxxx -pxxxxx

执行命令:

set @@global.sql_mode        ='NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

这样就好了。

现在说一下原理,首先我是怎么出这个问题了呢,是我升级了自己的mysql到5.7,然后原来5.6的一些旧语法就出了这样或者那样的问题,mysql5.7.5后,ONLY_FULL_GROUP_BY 默认为真,那么此时select中的字段必须出现在group by中,所以显而易见,旧新版本的问题。

官方文档在此:

A new function, ANY_VALUE(), is available that can be used to force

MySQL to accept queries that it thinks should be rejected with

ONLY_FULL_GROUP_BY enabled.
The function return value and type are

the same as the return value and type of its argument, but the

function result is not checked for the ONLY_FULL_GROUP_BY SQL mode.

If you find that having ONLY_FULL_GROUP_BY enabled causes queries for existing applications to be rejected, either of these actions should restore operation:

If it is possible to modify an offending query, do so, either so that

nondeterministic nonaggregated columns are functionally dependent on

GROUP BY columns, or by referring to nonaggregated columns using

ANY_VALUE().

If it is not possible to modify an offending query (for example, if

it is generated by a third-party application), set the sql_mode

system variable at server startup to not enable ONLY_FULL_GROUP_BY.

For more information about SQL modes and GROUP BY queries, see Server SQL Modes, and MySQL Handling of GROUP BY. (Bug #18486310)

mysql错误:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated的更多相关文章

  1. MySQL [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause

    MySQL[Err]1055 上次MySQL5.7.19主从建立完成之后,所有的测试都是在MySQL命令行下进行的,最近用Navicat Premium进行MySQL的连接,然后在插入数据的时候MyS ...

  2. mysql [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GRO

    [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c ...

  3. [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause 的问题 MySQL

    问题:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregate ...

  4. [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ'

    在Navicat Premium中执行Mysql的一条删除语句,虽然执行成功了,却提示已下错误: 受影响的行: 时间: .005s of ORDER BY clause is not in GROUP ...

  5. MySQL5.7.27报错[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated

    mysql5.7.27在运行更新语句时出现如下情况,mysql5.6之前没有这种情况出现. of ORDER BY clause is not in GROUP BY clause and conta ...

  6. [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause 的问题

    问题: [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregat ...

  7. navicat:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and ...

    mysql5.7,xshell下执行sql不会报下面的错,但是navicat会报错,可能是navicat版本问题,换其他客户端不会出现问题. [Err] 1055 - Expression #1 of ...

  8. mysql主给备赋予权限时报错,MySQL [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause

    https://www.cnblogs.com/skymyyang/p/7551646.html 在my.cnf 里面设置sql_mode='STRICT_TRANS_TABLES,NO_ZERO_I ...

  9. [bug]MySQL [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause

    参考 http://www.10qianwan.com/articledetail/220315.html

随机推荐

  1. django导出数据到excel

    import xlwt,StringIodef dumpData(request): #获取数据 activitys = Activity.objects.all().order_by('id') i ...

  2. python遍历当前目录并删除某文件

    #coding: utf-8 """ this programe is to clear driverlog below this dir __author__:the_ ...

  3. 140. Word Break II(hard)

    欢迎fork and star:Nowcoder-Repository-github 140. Word Break II 题目: Given a non-empty string s and a d ...

  4. Linux中ping不通外网

    在linux中ping www.baidu.com 无法ping通 需要修改vi /etc/resolv.conf 增加如下内容: nameserver 114.114.114.114 nameser ...

  5. VC++动态链接库(DLL)编程深入浅出(二)

    好,让我们正式进入动态链接库的世界,先来看看最一般的DLL,即非MFC DLL 上节给大家介绍了静态链接库与库的调试与查看,本节主要介绍非MFC DLL. 4.非MFC DLL 4.1一个简单的DLL ...

  6. wordpress账户防暴力破解攻击

    一.修改数据库表前缀 默认的表前缀是wp_,如果你安装博客的时候没有修改,可以参考这篇文章修改下表前缀. 修改完登录测试下,如果登录成功后提示“您没有足够的权限访问该页面”,说明前缀没有修改完整,参照 ...

  7. vue中使用key管理可复用的元素

    1.概述 Vue 会尽可能高效地渲染元素,通常会复用已有元素而不是从头开始渲染. key解决上述问题之外的情景:这两个元素是完全独立的,不要复用它们. 2.示例 <!DOCTYPE html&g ...

  8. 【剑指Offer学习】【面试题37:两个链表的第一个公共结点】

    题目:输入两个链表,找出它们的第一个公共结点. 链表结点定义 /** * 链表结点类 */ private static class ListNode { int val; ListNode next ...

  9. oracle学习之路(四) ---------PL/SQL 表,二维数组(TABLE)

    LOB类型 ORACLE提供了LOB (Large OBject)类型.用于存储大的数据对象的类型.ORACLE眼下主要支持BFILE, BLOB, CLOB 及 NCLOB 类型. NCLOB 存储 ...

  10. 利用xlrd模块实现Python读取Excel文档

    # -*- coding: cp936 -*- #python读取excel import xlrd def main(): xls=xlrd.open_workbook("d:\\11.x ...