查看Mysql连接数

文章介绍了MySQL中查看连接数的多种方法:使用SHOW STATUS查看当前连接数,查询information_schema.processlist查看各用户、客户端IP及状态,查看和修改最大连接数,超时设置,以及show full processlist获取详细连接信息。

作者:zhuge···预计阅读 3 分钟·1,386 阅读·0 评论
查看Mysql连接数

SHOW STATUS LIKE 'Threads%'; Threads_connected显示的数值就是当前的连接数

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

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

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

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

如果要修改最大连接数为500 set global max_connections=500;

也可以修改mysql配置文件max_connections=500,然后重启mysql生效

查看超时设置,可以在my.cnf中设置 show global variables like '%timeout%';

查看详细的用户连接信息 show full processlist

相关文章

评论

加载中...