king

mysql 8 查询报错(sql_mode=only_full_group_by)

king 数据库 2023-02-25 703浏览 0

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

mysql 8 查询报错(sql_mode=only_full_group_by)

mysql 5.7之后,查询如下:
  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
默认设置了:
  sql_mode=only_full_group_by
  only_full_group_by:使用它就和oracle一样的group规则,select的列都要在group中,或本身就是聚合列(sum,avg,max,min)才行,只要把它去掉即可。

处理方法:直接在Mysql配置文件中去掉该设置。

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

常用查询:

查询服务器运行状态
SHOW STATUS LIKE 'Thread%';

查看所有连接的状态
SHOW FULL PROCESSLIST

查询服务器的各种设置
SHOW VARIABLES LIKE 'max%';

临时设置最大连接数(重启会失效)
SET GLOBAL max_connections = 500

继续浏览有关 数据库技术文章/教程 的文章
发表评论