2017-08-08 29 views
1

我有一个在MySQL 5.6上运行良好的存储过程。在最近的服务器迁移期间,我们升级到了MySQL 5.7.19。存储过程引发“与sql_mode = only_full_group_by不兼容”尽管sql_mode为空

我的存储过程,现在抛出的错误:

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'utility-monitor.daily_readings.building_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by: CALL monthly_readings(2017, 1, NULL, 1, 1))

我已经设置了通过sql_mode""/var/mysql/my.cnf文件,重新启动mysql服务,并通过控制台登录,确认sql_mode通过为空白SELECT @@sql_mode;

尽管如此,我仍然在尝试运行存储过程时继续收到上述错误。

接下来可以做些什么来继续排除此错误来自何处?

+0

“ONLY_FULL_GROUP_BY”是MySQL 5.7中的默认值。 – Barmar

+0

https://stackoverflow.com/questions/23921117/disable-only-full-group-by检查此 – Jenish

回答

2

按照documentation,MySQL使用在创建过程,是活跃的SQL模式:用

MySQL stores the sql_mode system variable setting in effect when a routine is created or altered, and always executes the routine with this setting in force, regardless of the current server SQL mode when the routine begins executing.

所以重建程序(或所有,因为它可能不是唯一受到影响的一个)激活不同模式(或修复group by语法)。 改变虽然在文档中提到了该过程,但这还不够。您应该考虑不要永久更改sql模式(尽管您可能还有其他不兼容的代码)。

相关问题