当前位置:网站首页>【问题记录】03 连接MySQL数据库提示:1040 Too many connections
【问题记录】03 连接MySQL数据库提示:1040 Too many connections
2022-07-04 06:23:00 【joinclear】
1、报错信息如下:
连接MySQL数据库提示:1040 Too many connections:
2、原因:
由于数据库连接数量,超过了数据库的最大连接数。
PS:因为这些数据库连接数,处于sleep状态,但是还没有被清除掉。
查看原因:
1)登录数据库
登录服务器,输入命令:
mysql -uroot -p
输入数据库登录密码后,登录成功。
2)查看数据库进程状态
show status like 'Threads%';
treads_cached :缓冲池中的线程数。
Threads_connected:当前连接(运行和睡眠)中的线程数。
Threads_created :创建过连接的线程数。
Threads_running:当前运行(没有睡眠)中的线程数。
总共连接了:152个。
3)查看数据库最大连接数
show variables like '%max_connection%';
最大连接数:151个,小于当前连接总数152,所以提示:Too many connections。
4)查看清除Sleep连接数时间
show variables like 'wait_timeout';
清除时间间隔为:28800秒(8小时),连接后8小时清除掉。
3、解决方法:
解决方法优先按下面1、2、3的顺序:
1)排查代码问题
看看到底哪里产生的连接数过多,有可能是代码比如定时任务引起的问题。
2)增加最大连接数
set GLOBAL max_connections=1000;
比如,改为1000个连接数:
3)改小清除Sleep连接数时间
set GLOBAL wait_timeout=14400;
改成4小时清除或者更短的时间间隔。
边栏推荐
- C # symmetric encryption (AES encryption) ciphertext results generated each time, different ideas, code sharing
- 对List进行排序工具类,可以对字符串排序
- [untitled]
- 分布式CAP理论
- 雲原生——上雲必讀之SSH篇(常用於遠程登錄雲服務器)
- Common JS tool Libraries
- [openvino+paddle] paddle detection / OCR / SEG export based on paddle2onnx
- The difference between PX EM rem
- How to determine whether an array contains an element
- 配置交叉编译工具链和环境变量
猜你喜欢
如何避免 JVM 内存泄漏?
4G wireless all network solar hydrological equipment power monitoring system bms110
Sword finger offer II 038 Daily temperature
buuctf-pwn write-ups (8)
C实现贪吃蛇小游戏
云原生——上云必读之SSH篇(常用于远程登录云服务器)
How to avoid JVM memory leakage?
C language - Blue Bridge Cup - Snake filling
报错cvc-complex-type.2.4.a: 发现了以元素 ‘base-extension‘ 开头的无效内容。应以 ‘{layoutlib}‘ 之一开头。
Arcpy uses the updatelayer function to change the symbol system of the layer
随机推荐
Understanding of cross domain and how to solve cross domain problems
How to choose the middle-aged crisis of the testing post? Stick to it or find another way out? See below
C语言中的函数(详解)
复合非线性反馈控制(二)
Bicolor case
px em rem的区别
Invalid bound statement (not found): com. example. mapper. TblUserRecordMapper. login
Impact relay jc-7/11/dc110v
Native Cloud - SSH articles must be read on Cloud (used for Remote Login to Cloud Server)
gslb(global server load balance)技术的一点理解
QT 获取随机颜色值设置label背景色 代码
如何避免 JVM 内存泄漏?
How does apscheduler set tasks not to be concurrent (that is, execute the next task after the first one)?
测试岗的中年危机该如何选择?是坚守还是另寻出路?且看下文
A little understanding of GSLB (global server load balance) technology
Uninstall Google drive hard drive - you must exit the program to uninstall
2022.7.2-----leetcode.871
手动对list进行分页(参数list ,当前页,页面大小)
Install pytoch geometric
Which water in the environment needs water quality monitoring