事件起因

时间:2022.10.16

在开发自己的个人博客项目过程中,想要将本地数据库换成服务器上的数据库,于是将url换成了服务器上的url,其他地方不变

image-20221016172301119

接着重启springboot程序,访问数据库服务时出现了以下报错

image-20221016172518203

核心信息有以下几句

1
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
1
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server
1
Caused by: java.net.ConnectException: Connection timed out: connect

大概意思是连接出了问题,会话连接失败

springboot没有接收到服务器mysql发来的数据包

抛异常:连接超时

排查问题

账号或者密码错误?

以为是账号密码输入错了,于是在命令行连接了一下。发现可以连接上,就排除了这种可能

image-20221016173442023

springboot程序有问题?

程序在连接本地数据库时一切正常,且之前将程序放服务器上跑过(数据库为服务器上的),正常运行,数据库可以正常访问,所以这种可能也排除了

mysql配置有问题?

在使用相关命令时,发现过一段时间连接就断掉了,且有时会重连不上

image-20221016174047950

查看超时时间,为默认值

image-20221016192957649