Too many connections
在一次启动项目的过程中报了如下一个错误信息:
[ERROR] [2019-03-20 13:14:43] com.alibaba.druid.pool.DruidDataSource.init(629) | init datasource error
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Too many connections
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
at com.mysql.jdbc.Util.getInstance(Util.java:383)
意思是说链接太多了,分析下会出现这种情况的原因:
1.查看代码,是否在获取数据库连接,访问完数据库之后没有及时关闭数据库连接,释放资源
2.查看连接进程结束时间 wait_timeout — 指的是mysql在关闭一个非交互的连接之前所要等待的秒数
如果你没有修改过MySQL的配置,wait_timeout的初始值是28800
wait_timeout 过大有弊端,其体现就是MySQL里大量的SLEEP进程无法及时释放,拖累系统性能,不过也不能把这个指设置的过小,否则你可能会遭遇到“MySQL has gone away”之类的问题
3.看数据库的连接数设置,Mysql默认是100,以及增大数据库最大连接数
SHOW VARIABLES LIKE '%max_con%';
修改:(一般设置范围在500-1000之间)
SET GLOBAL max_connections = 1000;
可在MySQL配置文件my.ini直接找到对应的连接数max_connections和等待时间wait_timeout直接修改
如有需要可以加我Q群【308742428】大家一起讨论技术。
后面会不定时为大家更新文章,敬请期待。
喜欢的朋友可以关注下。
Too many connections的更多相关文章
- 解决mysql too many connections的问题
由于公司服务器上的创建的项目太多,随之创建的数据库不断地增加,在用navicat链接某一个项目的数据库时会出现too many connections ,从而导致项目连接数据库异常,致使启动失败. 为 ...
- Data source rejected establishment of connection, message from server: "Too many connections"解决办法
异常名称 //数据源拒绝从服务器建立连接.消息:"连接太多" com.MySQL.jdbc.exceptions.jdbc4.MySQLNonTransientConnection ...
- Configure Security Settings for Remote Desktop(RDP) Services Connections
catalogue . Configure Server Authentication and Encryption Levels . Configure Network Level Authenti ...
- 问题解决:psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
错误提示: psql: could not connect to server: No such file or directory Is the server running locally and ...
- Too Many Connections: How to Increase the MySQL Connection Count To Avoid This Problem
1.问题描述 在启动使用mysql数据库的项目时,遇到一个报错,如下: Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConn ...
- Configure the max limit for concurrent TCP connections(转)
To keep the TCP/IP stack from taking all resources on the computer, there are different parameters t ...
- 打开mysql时,提示 1040,Too many connections
打开mysql时,提示 1040,Too many connections,这样就无法打开数据库,看不了表里边的内容了. 出现这个问题的原因是,同时对数据库的连接数过大,mysql默认的最大连接数是1 ...
- mysql连接数设置操作(Too many connections)
mysql在使用过程中,发现连接数超了~~~~ [root@linux-node1 ~]# mysql -u glance -h 192.168.1.17 -pEnter password: ERRO ...
- Too many connections解决方案
原因: my.ini 中设定的并发连接数太少或者系统繁忙导致连接数被占满. 连接数超过了 MySQL 设置的值,与 max_connections 和 wait_timeout 都有关. wait ...
- 【JDBC 报错】Connections could not be acquired from the underlying database!
项目启动报错: [2016-07-13 10:04:15,074] ERROR org.apache.ibatis.executor.BaseExecutor Could not get a data ...
随机推荐
- si_da
1. apt-get 从互联网的软件仓库中搜索.安装.升级.卸载软件或操作系统 一般需要root权限执行,所以一般跟着sudo命令 sudo ifstat apt-get install -y ifs ...
- 如何创建并初始化程序集里List类型的反射
参考网址:http://stackoverflow.com/questions/315231/using-reflection-to-set-a-property-with-a-type-of-lis ...
- VB编程中的“Abs”是什么意思?
c = Val(Text1.Text) '将Text1中的值赋给cIf c = Abs(a - b) Then 'Abs(a - b)是a和b间的差(正数),判断c是否等于该差值f = f + 10 ...
- asp.net core web 项目附加进程调试
之前asp.net web项目在部署IIS站点的时候可以直接选择项目目录,不用发布,然后附加进程的时候,找到w3wp.exe开头的进程,再根据用户名找到要附加的进程,就可以附加进程调试了.但asp.n ...
- maven跳过测试编译命令
mvn clean install/package/deploy -Dmaven.test.skip=true
- C++实现文件内字符数、单词数、行数的统计
先给出github上的代码链接以及项目需求 1. 项目简介 这个项目的需求可以概括为:对程序设计语言源文件统计字符数.单词数.行数,统计结果以指定格式输出到默认文件中,以及其他扩展功能,并能够快速地处 ...
- Madlibs
name1 = input('请输入一个名字:') name2 = input('再输入一个名字:') animal = input('请输入一种动物:') print('一二三四五{}上山打{}不在 ...
- 从React组件划分的纠结到总结
在实际开发项目中,我将所有的React组件划分为容器组件和展示组件,展示组件其实就是一个纯函数组件,没有任何副作用,基本都是PureComponent.但是突然,出现了这么一个问题: 我有一个浮层组件 ...
- Educational Codeforces Round 58 (Rated for Div. 2) F dp + 优化(新坑) + 离线处理
https://codeforces.com/contest/1101/problem/F 题意 有n个城市,m辆卡车,每辆卡车有起点\(s_i\),终点\(f_i\),每公里油耗\(c_i\),可加 ...
- 数据结构C语言版-栈
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <iostream> ...