本人mysql安装在ubuntu16.04上,mysql版本是5.7.19;在创建表和插入数据时报了
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ‘ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
在网上查到的解决方案是修改/etc/mysql/my.cnf文件,在其中添加如下内容,然后重启mysql(重启命令:service mysql restart)
[mysqld] sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘
我尝试了之后,发现重启出现问题。
后来,我发现该版本的mysql配置引用了/etc/mysql/conf.d文件夹以及/etc/mysql/mysql.conf.d文件夹,且配置都放在了mysql.conf.d文件夹下的mysqld.cnf文件中,故将上述内容修改在该文件中,该文件中有[mysqld]
故只需要在该标签的后续内容添加
sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘
,并重启mysql。
完美解决。。。。
时间: 2024-09-28 20:01:53