首页> 开发问题 >服务器问题 服务器问题
MySQL报错:which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod
作者:小萝卜 2020-05-26 【 MySql 】 浏览 3279
简介网站换了服务器之后报错: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)
相关文章
- yum执行时Another app is currently holding the yum lock; waiting for it to exit... The other application is: yum
- Linux启动提示Kernel panic - not syncing: Attempted to kill init解决办法
- ckfinder报错:从服务器读取XML数据出错
- MySQL报错: SQLSTATE[HY000]: General error: 1030 Got error 28 from storage engine解决办法
- 什么情况:IP address '142.252.250.174' could not be resolved: ??֪?????????????? For more information
- IIS7.0运行PHP报错"php-cgi.exe - FastCGI 进程意外退出"
- The program 'yum' is currently not installed. You can install it by typing:
- Linux中“is not in the sudoers file”解决方法
- 可以ping通虚拟机但不能telnet 9000端口
- 网页提示错误(net::ERR_EMPTY_RESPONSE)