mysql的sql_mode问题

现在环境是phpstudy,数据库用的是mysql8.0

一般搭建thinkphp5.1的项目遇到sql_mode的翻页问题,如下

[SQL]SELECT * FROM ts_product GROUP BY type_id;
[Err] 1055 – Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘mall.ts_product.id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
 

一般数据会自动开启ONLY_FULL_GROUP_BY,严格的模式

 

查询

select @@sql_mode

复制内容,比如

ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

 

设置办法是:去 D:\phpstudy_pro\Extensions\MySQL8.0.12  每个人安装的不同,有个my.ini 

添加如下

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

mysql的sql_mode问题

 

重启mysql服务

再去程序看看,显示成功