当前位置: 代码迷 >> 综合 >> [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregate...
  详细解决方案

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregate...

热度:45   发布时间:2023-09-14 14:31:08.0

进行一个建表语句后mysql报错,主要信息如下:

[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

解决方案:

  • 方案一
    select version(),
    @@sql_mode;SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
    查看sqlmode方法:
mysql> select @@global.sql_mode;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| @@global.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 |
+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set
  • 方案二
    show variables like "sql_mode";
    set sql_mode='';
    set sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES';
  • 方案三
    在my.cnf 里面设置
    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
    保存,重启: service mysqld restart
windows中解决方案:
mysql> 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';
Query OK, 0 rows affected
  相关解决方案