情况
项目使用的数据库是客户直接购买的阿里云的服务器非搭建的
报错信息
SELECT list is not in GROUP BY clause and contains nonaggregated column ‘dangqun.bu.id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
原因
是在5.7下mysql的model默认为:ONLY_FULL_GROUP_BY
查询数据库model
SELECT @@GLOBAL.sql_mode;
解决
设置数据库model
set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';