mysql升级Caused by: com.mysql.jdbc.exceptions clause; this is incompatible with sql_mode=only_full_gr

mysql由5.7.22升级5.7.25版本的时候报Err1055异常Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column...
摘要由CSDN通过智能技术生成

mysql由5.7.22升级5.7.25版本的时候报Err1055异常

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
Expression #1 of ORDER BY clause is not in GROUP BY clause and contains 
nonaggregated column 'callcenter.CREATETIME' which is not functionally 
dependent on columns in GROUP BY clause; this is incompatible 
with sql_mode=only_full_group_by

修复方法:

  1. 首先登陆mysql

    mysql -uroot -p
    
  2. 登陆后使用命令 SELECT @@sql_mode;,查看sql_mode中确实有ONLY_FULL_GROUP_BY

    mysql>  SELECT @@sql_mode;
    +-------------------------------------------------------------------------------------------------------------------------------------------+
    | @@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 (0.00 sec)
    
    
  3. 更改mysql的sql_mode

    /etc/my.cnf文件里加sql_mode属性,值为上一步查询出来的,去掉ONLY_FULL_GROUP_BY即可
    如下:

    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
    
    [mysqld]
    #
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    # =====省略一部分内容=====
    
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    
    # =============这里就是修改后的sql_mode==================
    sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
    
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    
    
  4. 重启Mysql服务就可以

    service mysql restart
    

    如果系统没有上面的重启命令
    参考地址 https://blog.csdn.net/cx136295988/article/details/76690722

提示:
网上有些办法是用如下的sql指令去修改这个值,但是每次重启后会复原,只有修改my.cnf重启才有效果。

SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值