mysql5.7 gruop by报错this is incompatible with sql_mode=only_full_group_by

  1. 解析:在mysql 工具 搜索或者插入数据时报下面错误:

    ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘database_tl.emp.id‘ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

  2. 原因:

    看一下group by的语法:

    select 选取分组中的列+聚合函数 from 表名称 group by 分组的列

    从语法格式来看,是先有分组,再确定检索的列,检索的列只能在参加分组的列中选。

    我当前Mysql版本5.7.17,

    再看一下ONLY_FULL_GROUP_BY的意思是:对于GROUP BY聚合操作,如果在SELECT中的列,没有在GROUP BY中出现,那么这个SQL是不合法的,因为列不在GROUP BY从句中,也就是说查出来的列必须在group by后面出现否则就会报错,或者这个字段出现在聚合函数里面。

  3. 解决方法:

    (1) 只选择出现在group by后面的列,或者给列增加聚合函数;(不推荐)

    (2) 命令行输入:

    set @@GLOBAL.sql_mode=‘‘;

    set sql_mode =‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘;

    默认关掉ONLY_FULL_GROUP_BY!

    这个时候 在用工具select 一下

    SELECT @@sql_mode;

    SELECT @@GLOBAL.sql_mode;

    发现已经不存在ONLY_FULL_GROUP_BY ,感觉已经OK。但是如果你重启Mysql服务的话,发现ONLY_FULL_GROUP_BY还是会存在的。

    想要彻底解决这个问题 就得去改my.ini 配置(如果你们mysql 没有这个文件,就把my-default.ini 改成my.ini,我这个版本就是没有my.ini配置问题)

    在 [mysqld]和[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‘; 

原文地址:https://www.cnblogs.com/xiaolongui/p/12021657.html

时间: 2024-08-28 21:05:35

mysql5.7 gruop by报错this is incompatible with sql_mode=only_full_group_by的相关文章

mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by

在mysql 工具 搜索或者插入数据时报下面错误: ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'database_tl.emp.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with s

mysql报错this is incompatible with sql_mode=only_full_group_by

1.报错信息 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP BY, expression #2 of SELECT list contains nonaggregated column 'd.total_rated_power_transformer'; this is incompatible with sql_mode=only_full_group_b

mysql5.6版本备份报错

MySQL5.6版本备份报错,密码不安全 [[email protected] mysql]# mysqldump -uroot -ppassword cz-office > mysql38.sqlWarning: Using a password on the command line interface can be insecure. 解决方法1:进行交互式输入密码, [[email protected] mysql]# mysqldump -uroot -p cz-office > m

mysql-5.7.21启动报错、修改数据库存放目录

mysql-5.7.21启动报错.永久解决chmod +x /etc/rc.d/rc.local#往里面写入两条命令,意为开机自动创建mysqld并修改所有者权限 ehco "mkdir -p /var/run/mysqldchown -R mysql:mysql /etc/var/mysqld" /etc/rc.d/rc.local #修改数据库存放目录systemctl stop mysqld #将数据库服务器停止mkdir -p /data/mysql/ #创建目录chown -

(原)使用vectot的.end()报错:iterators incompatible

转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5070672.html 参考网址: http://blog.csdn.net/yxnyxnyxnyxnyxn/article/details/17610899 之前用vector一直没有问题,前几天遍历时, for (auto it = var.sta.begin(); it != var.sta.end();) 运行时直接报:iterators incompatible 网上搜了一下,很多是说使用e

Mysql5.7以上版本group by报错问题

问题描述 报错: ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'database_tl.emp.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full

sql_mode=ONLY_FULL_GROUP_BY 导致lepus监控mysql5.7报错

lepus监控mysql5.7出现的问题: 2017-09-12 12:18:53 [INFO] check mysql controller finished. [WARNING] check mysql 192.168.10.9:3306 failure: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'information_schema.proce

Mysql only_full_group_by以及其他关于sql_mode原因报错详细解决方案

(转载自:http://blog.csdn.net/wangyunfeis/article/details/77911704) Mysql only_full_group_by以及其他关于sql_mode原因报错详细解决方案 报错信息: 原因: 怎么查看呢: 解决办法1: 验证一下: 解决办法2 解决办法3 对于办法3解决的解释 对办法2办法3两种方法的说明 附上其他mode解释 对于其他mode说明 报错信息: 1.Error querying database.  Cause: com.my

Python - - MySQL数据库 - - 报错锦集

注:环境配置信息,系统环境CentOS 7.4,数据库版本 mysql-5.7.24 1,跳过授权表 # 在命令行跳过授权表命令 mysqld_safe --skip-grant-tables & # 在 my.cnf 文件配置跳过授权表命令 [mysqld] skip-grant-tables 2,更改root密码 # 方法一: update mysql.user set authentication_string=password('root') where user='root' and