mysql8 数据库迁移部署的一个常见文件备忘。。

 

 

1、sql_mode=only_full_group_by

sql_mode=only_full_group_by

 

Caused by: java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'adrms.this_.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

 

MySQL8默认开启这个功能,遇到一些group语句,就报错 了。

 

解决办法:

关闭sql_mode 的 only_full_group_by模式 only_full_group_by 要求 group by 后边必须写满 select 后边的非函数列,所以我们只需要关闭only_full_group_by即可,

关闭方式又分为 临时关闭 和 永久关闭 临时关闭:

临时关闭又分为Session级 和 GLOBAL级 Session:仅关闭当前会话设置,mysql重启后失效 GLOBAL:

关闭全局设置,mysql重启后失效

永久关闭:永久关闭only_full_group_by模式,这种方法需要在mysql的配置文件里修改,然后重启。

找到配置文件/etc/my.cnf(或则关联文件夹找到mysql-server.cnf) 在上述文件内的[mysqld]后追加sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION’ 保存配置文件后,

重启Mysql即可。

 

https://blog.csdn.net/qq_45076180/article/details/120805375

 

posted @ 2022-09-06 13:33  nanahome  阅读(69)  评论(0编辑  收藏  举报