服务器环境中

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. service worker介绍

    原文:Service workers explained 译者:neal1991 welcome to star my articles-translator, providing you advan ...

  2. 身为一个小白,看到一篇值得看的文章。讲述小白学习python的6个方法。

    01. Python怎么学?   Python虽然号称非常简单,功能强大!但是再简单,它也是一门编程语言,任何一个编程语言都会包含: 内功,心法和招式,内功心法就是指的算法,数据结构: 招式就是任何一 ...

  3. weakHashMap 用法

    WeakHashMap,此种Map的特点是: 当除了自身有对key的引用外,此key没有其他引用,那么GC之后此map会自动丢弃此值 当使用 WeakHashMap 时,即使没有显示的添加或删除任何元 ...

  4. zip loader

    GS.ZipAssetLoader = function(audioContext) { this.audioContext = audioContext, this.objLoader = new ...

  5. more - 在显示器上阅读文件的过滤器

    总览 (SYNOPSIS) more [-dlfpcsu ] [-num ] [+/ pattern] [+ linenum] [file ... ] 描述 (DESCRIPTION) More 是 ...

  6. C# 异常处理最佳实践,解决代码分析提示CA1031:不要捕捉一般异常类型的解决办法

    异常类型 异常一般分为系统异常 和 应用异常.系统异常有无法连接数据库,而应用异常是业务逻辑异常,比如授权失败. 在 C# 中异常基于 System.Exception,派生出 System.Syst ...

  7. 树莓派 msmtp和mutt 的安装和配置

    1,安装mutt sudo apt-get install mutt 2,安装msmtp sudo apt-get install msmtp 3,设置mutt /etc/Muttrc # 系统全局设 ...

  8. P1864 [NOI2009]二叉查找树

    链接P1864 [NOI2009]二叉查找树 这题还是蛮难的--是我菜. 题目描述中的一大堆其实就是在描述\(treap.\),考虑\(treap\)的一些性质: 首先不管怎么转,中序遍历是确定的,所 ...

  9. windows下zookeeper集群安装

    windows下zookeeper单机版安装,见:https://www.cnblogs.com/lbky/p/9867899.html 一:zookeeper节点为什么是奇数个? 单机模式的zk进程 ...

  10. php strripos()函数 语法

    php strripos()函数 语法 作用:寻找某字符串中某字符最后出现的位置,不区分大小写.大理石平台 语法:strripos(string,find,start) 参数: 参数 描述 strin ...