MySQL问题 远程连接数被占满

设置MySQL单用户远程最大连接数是3

set GLOBAL max_user_connections=3;

查看连接数限制

show variables like '%connections';

其中,max_connections控制远程连接数和本地连接数总和上限。

尝试继续创建远程连接失败

情况1:max_connections比max_user_connections大

通过本地连接登录MySQL,查看数据库连接情况
show full processlist;
即select * from information_schema.processlist

情况2:max_connections与max_user_connections相等

无法通过本地连接登录MySQL
1. 进入MySQL容器并查看网络连接,确定连接调用方
docker inspect mysql | grep -i pid
nsenter -t 17822 -n lsof -i:3306

2. 分析SQL

查看mysqld进程打开的业务数据库表文件
lsof -p 9191 | grep "/var/lib/mysql/" | grep -e "\.ibd" | grep -v "/var/lib/mysql/mysql"

看到了打开test.student表,但是实际上没有执行相关SQL。

posted on 2024-04-04 14:14  王景迁  阅读(22)  评论(0编辑  收藏  举报

导航