首页> 开发问题 >服务器问题 服务器问题
MySQL报错:which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod
作者:小萝卜 2020-05-26 【 MySql 】 浏览 3785
简介网站换了服务器之后报错:which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod
换了服务器之后,mysql从5.6也换成了5.7,使用如下sql语句会报错:
select * from my_student group by class_id;
报错:
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'mydatabase1.my_student.stu_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
错误的原因是我mysql版本换成了5.7的,使用如下语句查询可知
select @@sql_mode;
里面默认设置了
sql_mode=only_full_group_by
only_full_group_by :使用这个就是使用和oracle一样的group 规则, select的列都要在group中,或者本身是聚合列(SUM,AVG,MAX,MIN) 才行,其实这个配置目前个人感觉和distinct差不多的,所以去掉就好
Windows 服务器直接在my.ini 配置文件添加如下:
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Linux服务器则在etc/my.cnf配置文件加入上面的代码。
最后重启服务器,OK正常使用。
很赞哦! (2)
相关文章
- 网页提示错误(net::ERR_EMPTY_RESPONSE)
- Linux启动提示Kernel panic - not syncing: Attempted to kill init解决办法
- 什么情况:IP address '142.252.250.174' could not be resolved: ??֪?????????????? For more information
- 重启服务器之后 网站报错SQLSTATE[HY000] [2002] Connection refused
- cp: omitting directory `/www/yingcaizhibo/filespath/flash'复制文件出错
- The program 'yum' is currently not installed. You can install it by typing:
- 解决linux安装软件:/lib/ld-linux.so.2: bad ELF interpreter问题
- yum执行时Another app is currently holding the yum lock; waiting for it to exit... The other application is: yum
- MySQL报错: SQLSTATE[HY000]: General error: 1030 Got error 28 from storage engine解决办法
- polkit pkexec 本地提权漏洞(CVE-2021-4034)解决办法