大佬文章请优先查看:
mysql查看当前连接数
查看3306端口连接数
| netstat -net | grep -i '3306' | wc -l |
查看当前连接数
| SHOW STATUS LIKE 'Threads%'; |

查看当前各用户连接数据库的数量
| select USER, count(*) from information_schema.processlist group by USER; |

查每个ip连接数据库的数量
| SELECT substring_index(host, ':',1) AS host_name,count(*),DB FROM information_schema.processlist GROUP BY DB,host_name; |
查看连接到数据库的账号、客户端ip及各连接数
| SELECT user,substring_index(host, ':',1) AS host_name,state,count(*) FROM information_schema.processlist GROUP BY state,host_name; |

查看MySQL最大连接数
| SHOW VARIABLES LIKE '%max_connections%'; |

修改MySQL最大连接数
如果要修改最大连接数为500
| set global max_connections=500; |
也可以修改mysql配置文件max_connections=500
,然后重启mysql生效

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步