Docker解决MySQL 5.7 报错 sql_mode=only_full_group_by

原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/17049850.html

 

使用如下语句查询mysql当前version

select version();

查出

5.7.40

 

使用如下语句查询mysql当前的sql mode

select @@sql_mode;

查出

ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

 

直接在MySQL客户端执行如下语句

SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
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';

再次查询sql mode,已经没有ONLY_FULL_GROUP_BY

STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

 

重启项目即可,发现程序不再报错

 

posted @ 2023-01-13 15:44  李白与酒  阅读(572)  评论(0编辑  收藏  举报