mysql数据库语句错误(mysql数据库常见报错之Timeout)

概述

在观察某个数据库错误日志的时候发现一直在刷错误信息:

2019-09-20T07:41:17.933680Z 1936 [Note] Aborted connection 1936 to db: 'test' user: 'fsl' host: 'xxxx' (Got timeout reading communication packets)

mysql数据库语句错误(mysql数据库常见报错之Timeout)(1)

这个问题还是比较常见的,下面简单记录一下解决过程。


思路

可能导致Got Timeout reading communication packets错误的原因有如下几个:

  • A client attempts to access a database but has no privileges for it.(没有权限)
  • A client uses an incorrect password.(密码错误)
  • A connection packet does not contain the right information.(连接没有包含正确信息)
  • It takes more than connect_timeout seconds to obtain a connect packet. (获取连接信息起过connect_timeout的时长)
  • The client program did not call mysql_close() before exiting.(客户端没有调用mysql_close()函数)
  • The client had been sleeping more than wait_timeout or interactive_timeout seconds without issuing any requests to the server. (客户端的空连接时间过长,超过了wait_timeout和interactive_timeout的时间)
  • The client program ended abruptly in the middle of a data transfer.(数据传输过程中终结)

1、调整max_allowed_packet参数

max_allowed_packet=500M

发现调整后还是有类似问题。


2、查看系统断开时间

show variables like '%timeout%';

mysql数据库语句错误(mysql数据库常见报错之Timeout)(2)

参数介绍 :

首先说明两个关键词 通过MySQL 客户端连接db的是交互会话,通过jdbc等程序连接db的是非交互会话

interactive_timeout: MySQL服务器关闭交互式连接前等待的秒数。交互式客户端定义为在mysql_real_connect()中使用CLIENT_INTERACTIVE选项的客户端。参数默认值:28800秒(8小时)

wait_timeout: MySQL服务器关闭非交互连接之前等待的秒数。在会话启动时,根据全局wait_timeout值或全局interactive_timeout值初始化会话wait_timeout值,取决于客户端类型--由mysql_real_connect()的连接选项CLIENT_INTERACTIVE定义。参数默认值:28800秒(8小时)


3、配置文件注释这两个参数,重启数据库服务

mysql数据库语句错误(mysql数据库常见报错之Timeout)(3)


4、重新观察

mysql数据库语句错误(mysql数据库常见报错之Timeout)(4)


觉得有用的朋友多帮忙转发哦!后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下~

mysql数据库语句错误(mysql数据库常见报错之Timeout)(5)

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页