报错信息:
......not in GROUP BY clause and contains nonaggregated column ...... which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
查看sql_mode: select @@sql_mode
原因:一些MySQL的版本默认设置了:sql_mode=only_full_group_by
解决办法:
①到Linux中找到/ect/my.cnf (我的是CentOs7 )
②编辑文件:
③,先到执行命令:select @@sql_mode,
将only_full_group_by去掉,在复制里面的内容,设置进配置文件中,如上图。
④重启mysql服务:service mysqld restart