在本地启动项目后,发现控制台报如下错误
bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'data_show.t.target_number' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
发现错误原因是
sql_mode=only_full_group_by
于是查阅资料,发现有可能是我本地安装的mysql用的是默认配置,虽然其他项目运行相同的脚本可以通过,但是不知为何这个项目会报这个错误,修改如下配置即可
sudo vim /etc/my.cnf #没有的话就创建一个 #将sql_mode 的值改为'' sql_mode = ''
修改完成后,重启mysql,然后查看配置
show variables like '%sql_mod%';
最后附上官方的解释:点击查看