ERROR 1055 (42000): Expression #1 of ORDER BY clause is not in GROUP BY..sql_mode=only_full_group_by


MySQL错误:Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'DB.table.column' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by


解决办法1:

(临时)在命令行中登陆Mysql,执行:

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';


解决办法2:

(永久)在Mysql的配置文件my.cnf修改sql_mode值(去掉里面的ONLY_FULL_GROUP_BY),重启MySQL即可。


----- 配置文件my.conf在哪 -----

(0)Linux下,参考:Linux下MySQL配置文件my.ini位置,http://www.linuxidc.com/Linux/2013-01/77389.htm

(1)OSX下,需要自己复制出来, sudo cp /usr/local/mysql/support-files/my-medim.cnf /etc/my.cnf,重启mysql即可

(2)windows下,参考Windows下MySQL5.6查找my.ini配置文件,http://blog.csdn.net/mayor125/article/details/54140454






你可能感兴趣的:(Mysql)