当前位置:网站首页>columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by mysql8.0解决办法
columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by mysql8.0解决办法
2022-07-26 04:37:00 【祖安大龙】
问题如下:
ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘jol.solution.nick’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
原因:
mysql5.7以上默认开启了only_full_group_by选项。我的版本是mysql8.0以上的
Windows解决办法:
先查询查看sql_mode中的内容
select @@GLOBAL.sql_mode;
+-----------------------------------------------------------------------------------------------------------------------+
| @@GLOBAL.sql_mode |
+-----------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------------------------------+
解决办法有两种,第一种是临时解决,不治本,数据库重启还会重新出现此问题,第二种是修改my.ini配置文件,治本,也方便
办法1:
将查询到的sql_mode中ONLY_FULL_GROUP_BY删去即可,重启就会失效
set @@GLOBAL.sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
办法2:
先找到自己mysql安装路径
select @@basedir;
+-----------+
| @@basedir |
+-----------+
| E:\mysql\ |
+-----------+
然后进入文件夹找到自己的my.ini配置文件,修改[mysqld]中的内容,添加下面的内容就可以

一定要加在[mysqld]里面,就是下面这行代码,就是将查询到的sql_mode中ONLY_FULL_GROUP_BY删去
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
然后退出数据库,在服务里面重启MySQL就可以
Ubuntu系统/Linux系统解决办法
我的数据库配置文件存在 /etc/mysql/mysql.conf.d/mysqld.cnf 里,所以直接打开这个文件
vim /etc/mysql/mysql.conf.d/mysqld.cnf
打开文件后键入
i #插入命令
会进入这个配置文件
可能会出现这个情况鼠标滚轮下滑没用,使用键盘按键下拉就行
跟windows一样,添加sql_mode,也是删除ONLY_FULL_GROUP_BY后的那一串东西,加进入后键入键盘左上角的Esc,就会退出插入模式,然后再键入 :wq 后回车就可以保存文件,然后再重启MySQL就可以
重启命令:
sudo service mysql restart
然后进入MySQL输入下面的代码查看,即可
select @@GLOBAL.sql_mode;

边栏推荐
- Getting started with mongodb Basics
- Steam science education endows classroom teaching with creativity
- 2022杭电多校第二场 A.Static Query on Tree(树剖)
- 【UOJ 429】串串划分(Runs)(容斥)+ 有关 Lyndon Tree 及其应用的小小记录
- Page pull-up refresh and pull-down loading
- egg-ts-sequelize-CLI
- 7、 Restful
- 补位,稍后补上
- Array sort 3
- The auxiliary role of rational cognitive educational robot in teaching and entertainment
猜你喜欢

User defined type details

Chapter 3 how to use sourcetree to submit code

A series of problems about the number of DP paths

人脸数据库收集总结

Li Kou daily question - day 42 -661. Picture smoother

计算离散点的曲率(matlab)

Steam science education endows classroom teaching with creativity

Face database collection summary

数组排序2

Tutorial on using the one click upgrade function of the rtsp/onvif protocol video platform easynvr service
随机推荐
MySQL only checks the reasons for the slow execution of one line statements
第三篇如何使用SourceTree提交代码
Build a maker Education Laboratory for teenagers
MapReduce中分区数与ReduceTask个数关系比较
How does win11 change the power mode? Win11 method of changing power mode
数据库启动报:ORA-29702: error occurred in Cluster Group Service
[enterprise micro procedure]
How does win11 set the theme color of the status bar? Win11 method of setting theme color of status bar
Calculate the curvature of discrete points (matlab)
SQL加解密注入详解
Spark Structured Streaming HelloWorld
Postman imports curl, exports curl, and exports corresponding language codes
MySQL log classification: error log, binary log, query log, slow query log
「游戏引擎 浅入浅出」4. 着色器
Credit card fraud detection based on machine learning
MySQL日志分类:错误日志、二进制日志、查询日志、慢查询日志
补位,稍后补上
Analyzing the curriculum design evaluation system of steam Education
解决 Incorrect string value: ‘\xF0\x9F\x98\xAD“,...‘ for column ‘commentContent‘ at row 1 报错
Spark Structured Streaming HelloWorld