当前位置:网站首页>mysql报错:Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
mysql报错:Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
2022-06-29 15:37:00 【持久的棒棒君】
问题描述
报错提示
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设置的有问题。Mysql可以支持不同的SQL模式,不同的SQL模式会有不同的语法,执行不同的数据校验简查。
MySQL5.7版本以上默认设置了 mysql sql_mode = only_full_group_by 属性,导致报错。
解决
方式一:临时解决(重启mysql后会仍会报错)
第一步SELECT @@sql_mode;
查询结果为:
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
第二步
去掉ONLY_FULL_GROUP_BY 重新设置值
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';
第三步
上面是改变了全局sql_mode 对于新建的数据库有效, 对于已存在的数据库,则需要在对应的数据下执行:SET sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
方式二:永久解决方式- 修改配置文件
window电脑修改mysql中的my.ini配置文件,linux和max修改myslq中的my.ref文件
具体操作:
在[mysqld]段下,添加如下内容
对于mysql5.7版本:sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
对于8版本以上:去掉NO_AUTO_CREATE_USER,如下sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
边栏推荐
- 面试官:说一下MySQL事务隔离级别?
- GWD:基于高斯Wasserstein距离的旋转目标检测 | ICML 2021
- C. Most Similar Words
- Leetcode-470- implement rand10() with rand7()
- 发明了杀毒软件之后,他选择做一个极品混混
- Basic composition of radar
- 防范企业数据泄露,就用网络安全产品堡垒机!
- 为Golang项目编写Makefile
- 关于 麒麟系统启动应用报错“undefined symbol: __cxa_throw_bad_array_new_length, version Qt_5“ 的解决方法
- Summary of recent work
猜你喜欢

Volcano engine was selected into the first "panorama of edge computing industry" in China

C#学习一:值类型与引用类型

Mingdeyang xilinx-k7-325t/410t core board data manual

CVPR 2022 | greatly reduce the manual annotation required for zero sample learning. Mapuosuo and Beiyou proposed category semantic embedding rich in visual information

瓜分1000+万奖金池,昇腾AI创新大赛2022实力赋能开发者

天谋科技 Timecho 完成近亿元人民币天使轮融资,围绕 Apache IoTDB 打造工业物联网原生时序数据库

Leetcode-64- minimum path sum

攻防演练之战前扫雷:漏洞管理的5大措施

12.UDP协议-bite

Building SQL statements in Excel
随机推荐
Go标准库Context包:单个请求多个goroutine 之间与请求域的数据、取消信号、截止时间等相关操作
LeetCode-64-最小路径和
Neural network for remote sensing image processing
MySQL XA distributed transaction
C. Most Similar Words
架构实战营模块五作业
京东健康回应拟以 3.554 亿美元收购京东资产:与宠物健康产品品类相关
再也不用担心窗体变形了
Numpy 的研究仿制 1
Applet judges that the data is not empty
BFD principle and configuration
有望显著提高集成光子电路的计算性能,清华团队提出了一种衍射图神经网络框架
Rust Basics
Google software version experience cycle
The role of each layer in convolutional neural network
What is the time complexity of the redis command?? (the actual question is about the underlying structure of redis)
Summary of recent work
wallys/m.2/Adapter card(one pcie1x to 4 x Mini PCIE)
天谋科技 Timecho 完成近亿元人民币天使轮融资,围绕 Apache IoTDB 打造工业物联网原生时序数据库
postgresql源码学习(23)—— 事务日志④-日志组装