当前位置:网站首页>【问题记录】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小时清除或者更短的时间间隔。
边栏推荐
- Nexus 6p从8.0降级6.0+root
- Invalid revision: 3.18.1-g262b901-dirty
- Lightroom import picture gray / Black rectangular multi display
- ORICO ORICO outdoor power experience, lightweight and portable, the most convenient office charging station
- Nexus 6p downgraded from 8.0 to 6.0+root
- 4G wireless all network solar hydrological equipment power monitoring system bms110
- C réaliser des jeux de serpents gourmands
- gslb(global server load balance)技术的一点理解
- How to implement cross domain requests
- Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
猜你喜欢

AWT common components, FileDialog file selection box

雲原生——上雲必讀之SSH篇(常用於遠程登錄雲服務器)

buuctf-pwn write-ups (8)

注释与注解

The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function

如何实现视频平台会员多账号登录

27-31. Dependency transitivity, principle

复合非线性反馈控制(二)

APScheduler如何设置任务不并发(即第一个任务执行完再执行下一个)?

Inputstream/outputstream (input and output of file)
随机推荐
ES6 modularization
运算符<< >>傻瓜式测试用例
My NVIDIA developer journey - optimizing graphics card performance
[March 3, 2019] MAC starts redis
MySQL的information_schema数据库
740. Delete and get points
Distributed cap theory
A little understanding of GSLB (global server load balance) technology
Internet of things protocol ZigBee ZigBee module uses the concept of protocol stack
How to use multithreading to export excel under massive data? Source code attached!
Sword finger offer II 038 Daily temperature
Detectron: train your own data set -- convert your own data format to coco format
4G wireless all network solar hydrological equipment power monitoring system bms110
手动对list进行分页(参数list ,当前页,页面大小)
7. Agency mode
2022.7.2-----leetcode. eight hundred and seventy-one
雲原生——上雲必讀之SSH篇(常用於遠程登錄雲服務器)
24 magicaccessorimpl can access the debugging of all methods
How to solve the component conflicts caused by scrollbars in GridView
Leakage detection relay jy82-2p