首页 > 数据库技术 > 详细

深圳风采直播:mysql错误:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated

时间:2018-04-10 14:26:37      阅读:8227      评论:0      收藏:0      [点我收藏+]

深圳风采开奖直播 www.nskjr.cn 标签:inf   新版   官方   express   dep   eject   .sql   nis   available   

今天迁移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

标签:inf   新版   官方   express   dep   eject   .sql   nis   available   

原文:https://www.cnblogs.com/Yemilice/p/8778471.html

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
? 2014 深圳风采开奖直播 版权所有 鲁ICP备09046678号-4
打开技术之扣,分享程序人生!
             

鲁公网安备 37021202000002号

  • 价值-热门标签-华商生活 2019-05-19
  • 以古鉴今,习近平多次提及屈原 2019-05-18
  • 候选企业:内蒙古蒙草生态环境(集团)股份有限公司 2019-05-18
  • 埃里克森:中国将成为足球大国 15年内能进四强 2019-05-17
  • 审计署:19万套房子空置 数百亿元资金闲置 2019-05-17
  • 广东清远黑臭水体整治弄虚作假 6名责任人被立案调查 2019-05-16
  • 推动实现更高质量和更充分就业 2019-05-15
  • 暴雨突袭石泉 干部背群众转移到安全地带 2019-05-15
  • 人体-热门标签-华商生活 2019-05-14
  • 改革开放40载,互联网的发展风云激荡 2019-05-14
  • 杭州高新区(滨江):“智慧社区”助推社区治理服务创新 2019-05-13
  • 法治中国,走向更美好的明天(砥砺奋进的五年·全面依法治国) 2019-05-13
  • 斯柯达速派2017年上半年累计销量同比上涨36% 2019-05-12
  • 浙江台州副市长出庭应诉民告官案 称要作表率 2019-05-12
  • 罗品禧的专栏作者中国国家地理网 2019-05-11
  • 254| 101| 462| 455| 414| 159| 843| 891| 561| 692|