服务器环境中

JAVA 连接数据库 Communications link failure, Contection refused

网上很多这种情况,解决基本上是将127.0.0.1换成localhost

但是我这个比较傻b,原因也很无奈。值得纪念,以下是我解决的过程,过程还是值得学习的。

1、症状:java 连接数据库 访问拒绝 连接拒绝。

  原因:基本上是围绕着 IP,PORT,DB,USERNAME,PASSWORD这几个参数,只能是这里出了问题。 

  过程:将127.0.0.1换成localhost,还是不行,修改timeout时间也不行(如果修改超时时间就可以了,你应该查看是什么原因造成连接时间过长)

  原因:原来是数据库停止了,是IP参数造成的。

为什么mysql停止了呢?

2、症状:java连接数据库,出现 mysqld killed。。(比较隐蔽,一般看不到)查看mysql状态,显示mysql dead。。

  原因:一般正常来说,mysqld是被mysqld_safe管理的,mysqld_safe相当于一个守护进程,一般mysql出现错误,停止后,mysqld_safe会自动重启mysql

      然而,mysqld 却 dead 了,这显然不正常,说明mysqld_safe没有重启mysql,或重启失败了。

  过程:查看mysqld_safe日志,确实显示重启失败。

  原因:内存不够了。。。。。。。

原来,mysql启动时会创建一个默认128M的缓冲池,当时服务器上跑的程序太多了,连128M都分不出来了。

解决:升级服务器,关闭不需要的程序,调低mysql  buffer pool 大小

Communications link failure mysql自动停止 连接拒绝 mysqld dead but sub。。。的更多相关文章

  1. 解决MySQL连接超时Communications link failure due to underlying exception

    最近在用一个MySQL的Java连接池的过程中,连接一晚上不释放,第二天就会造成超时的错误,查了一下原因,原来是因为MySQL默认的空闲等待时间是8个小时,一旦空闲超过8个小时,就会抛出异常.异常文本 ...

  2. jdbc 连接mysql Communications link failure的解决办法

    使用Connector/J连接MySQL数据库,程序运行较长时间后就会报以下错误: Communications link failure,The last packet successfully r ...

  3. mysql连接com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    现象:客户端连接服务器端mysql是没问题的,所有都木有问题,应用程序配置也没问题,但是连接就抛异常: com.mysql.jdbc.exceptions.jdbc4.CommunicationsEx ...

  4. Java连接MySQL报错:CommunicationsException: Communications link failure

    现象: 报错:Exception in thread "main" com.mysql.cj.jdbc.exceptions.CommunicationsException: Co ...

  5. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解决办法

    09:00:30.307 [http-8080-6] ERROR org.hibernate.transaction.JDBCTransaction -JDBC begin failed com.my ...

  6. Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    很长的报错,截取   ERROR c.a.d.p.DruidDataSource - discard connection   com.mysql.jdbc.exceptions.jdbc4.Comm ...

  7. mysql 5.1超过默认8小时空闲时间解决办法(错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure)

    报错: MySQL第二天早上第一次连接超时报错, com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications lin ...

  8. Mysql Communications link failure 问题的解决

    问题现象 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last p ...

  9. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 解决

    感谢大佬:https://blog.csdn.net/a704397849/article/details/93797529 springboot + mybatis多数据库 + druid连接池配置 ...

随机推荐

  1. mysqldump导入导出

    如果导入数据:使用mysqldump命令 导出数据和表的结构: 1.导出表数据和表结构 mysqldump -u用户名 -p密码 数据库名 > 数据库名.sql(这个名字随便叫) #/usr/l ...

  2. mongoDB学习笔记(2)

    一.删数据库 1.语法 MongoDB 删除数据库的语法格式如下: db.dropDatabase() 删除当前数据库,默认为 test,你可以使用 db 命令查看当前数据库名. 2.实例 以下实例我 ...

  3. python 安装 pip ,并使用pip 安装 filetype

    闲话少说,直接上操作. python版本为2.7.6 可以直接到官网下载,我也提供一个百度云的下载地址 https://pan.baidu.com/s/1kWPXG8Z 这个是window版本,lin ...

  4. 按字节读取txt文件缓存区大小设置多少比较好?

    读取 txt 文件常规写法有逐行读取和按照字节缓存读取,那么按照字节缓存读取时,设置缓存区多大比较好呢?百度了一下,没发现有说这个问题的,自测了一把,以事实说话. 常规读取方法如下: // 字节流读取 ...

  5. 一、.Net Core 分块上传文件

    一..Net Core 分块上传文件 一.前端实现 @* For more information on enabling MVC for empty projects, visit http://g ...

  6. zabbix 4.2 发送警告邮件Python脚本

    #!/usr/bin/env python#-*- coding: UTF-8 -*-import os,sysimport getoptimport smtplibfrom email.MIMETe ...

  7. oracle 使用escape转义%与_匹配字符为本来含义

    举例: 查找姓名为M%的员工. select * from employee where staff_name like 'M\%' escape '\';

  8. Mac xlwings aem.aemsend.EventError: Command failed: The user has declined permission. (-1743)

    aem.aemsend.EventError: Command failed: The user has declined permission. (-1743) 关于mac pycharm 使用xl ...

  9. C++ begin()和end()

    begin(a)指向数组a的第一个元素,end(a)指向数组a最后一个元素之后的一个元素 #include <iostream> using namespace std; int main ...

  10. wine安装与配置

      1. 安装wine32dpkg --add-architecture i386 && apt-get update && apt-get install wine3 ...