0%

MySql中only_full_group_by的问题解决

首先查看mysql的sql_mode:

1
2
3
4
5
6
7
mysql> select @@sql_mode;
+----------------------------------------------------------------------------------------------------+
| @@sql_mode |
+----------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+----------------------------------------------------------------------------------------------------+
1 row in set (0.25 sec)

可以看到ONLY_FULL_GROUP_BY,我们需要关闭它。

1
2
3
4
5
vi /etc/mysql/conf.d/custom.cnf

[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
#没有only_full_group_by

最后重启mysql。