解决MySQL报错:“The last packet sent successfully to the server was 0 milliseconds ago.”

这篇具有很好参考价值的文章主要介绍了解决MySQL报错:“The last packet sent successfully to the server was 0 milliseconds ago.”。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

问题原因:

之所以出现异常,是由于数据库回收了连接,而系统的缓冲池不知道,继续使用被回收的连接所致的。

解决方案1:

方法就是将mysql回收空闲连接的时间变长,mysql默认回收时间是8小时,可以在mysql目录下的my.cnf中增加下面配置,将时间改为1天。

单位是秒,最大好像是24天:

 [mysqld]

wait_timeout=86400  //加上这一句

执行下面SQL语句查看超时时间

show global variables like 'wait_timeout'

解决方案2:

判断连接url是否正确(useSSL为false)文章来源地址https://www.toymoban.com/news/detail-714345.html

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/demo?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=false

到了这里,关于解决MySQL报错:“The last packet sent successfully to the server was 0 milliseconds ago.”的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • The last packet sent successfully to the server was 0 milliseconds ago.问题分析

    英文描述 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 中文描述: 上次成功发送到服务器的数据包是0毫秒前。驱动程序尚未从服务器收到任何数据包。 检查db链接地址,如果db无法连接,那么会出现这个错误,问题描述为

    2024年02月11日
    浏览(10)
  • mysql链接错误The last packet successfully received from the server was xxx milliseconds ago解决方案

    mysql链接错误The last packet successfully received from the server was xxx milliseconds ago解决方案

    线上项目偶尔出现错误,这个错误发现是在项目无人操作一段时间后就产生,如果有人操作,那就不会出现。 具体报错信息 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 385,290,819 milliseconds ago. The last packet sent successfully to the server was

    2024年02月03日
    浏览(9)
  • 解决The plain HTTP request was sent to HTTPS port

    现在越来越多的网站要求 http 访问转为更为安全的 https 访问,很多使用nginx部署的前端应用可以很方便的使用反向代理来实现,切换后,用http访问就会出现 \\\"The plain HTTP request was sent to HTTPS port\\\"的错误页面。 将此错误页面重定向到指定的https地址即可 假设端口号是8443: 另外,

    2024年02月11日
    浏览(12)
  • 解决com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure, The last packe.

    目录 解决com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure, The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 步骤1: 检查网络连接 步骤2: 检查MySQL服务器设置 步骤3: 检查数据库连接参数 步骤4: 检查MySQL驱动程序版本

    2024年02月04日
    浏览(29)
  • 如何解决MySQL报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL?

    如何解决MySQL报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL?

    目录 ​​​​​​​ 📢CHECK约束 📢那么会遇到什么问题呢? 📢那么关于如何使用CHECK约束进行检查,以下是一个简单的演示:          ✨ CHECK约束用于在插入或更新数据时对列值进行条件检查。它允许你定义一个条件,确保将要插入或更新的数据满足特定的要求。如

    2024年01月23日
    浏览(16)
  • git lfs 完美解决 Use `git lfs logs last` to view the log.error: external filter ‘git-lfs filter-proces

    git lfs 完美解决 Use `git lfs logs last` to view the log.error: external filter ‘git-lfs filter-proces

    问题 : 用git lfs 或者 git 下载github项目失败报错:Clone succeeded, but checkout failed. 解决办法: 第一步: git lfs install --skip-smudge 第二步: git config --global core.longpaths true 第三步: 初始化.git文件: git init 第四步: 然后删除全部文件,包括 .git 文件, 重新使用命令克隆下载我们想要下

    2024年02月10日
    浏览(11)
  • The plain HTTP request was sent to HTTPS port

    The plain HTTP request was sent to HTTPS port

    异常信息 原因 错误信息 “The plain HTTP request was sent to HTTPS port” 表明客户端尝试使用未加密的HTTP协议发送请求到一个配置为使用加密的HTTPS协议的端口。 解决方案 要解决这个问题,需要确保使用正确的协议和端口号进行请求。应该使用的HTTPS前缀。例如: 错误的请求: ht

    2024年04月14日
    浏览(9)
  • 400 The plain HTTP request was sent to HTTPS port

    400 The plain HTTP request was sent to HTTPS port

    接口请求发生问题: 解决方法: Nginx HTTP 服务器的报错 “ 400 Bad Request: The plain HTTP request was sent to HTTPS port ”,本文将讲解如何解决这个问题。 简单从报错的字面意思上来看,是因为HTTP请求被发送到HTTPS端口,这种报错多出现在Nginx既处理HTTP请求又处理HTTPS请求的情况。 以下

    2024年02月08日
    浏览(14)
  • [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

    如果你的node.js提示: [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client 那么,代表你返回了结果,但是最后你又不小心再返回了一次。通常是由于方法没有进行等待,或者多条件判断缺漏造成的。 情况一:返回机制问题 通过success/error模式来返回结果,取消最终的

    2024年02月10日
    浏览(13)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包