mysql线程和连接数查询

查看mysql使用的线程模式

show variables like ‘%thread_handling%’;
+—————–+—————————+
| Variable_name | Value |
+—————–+—————————+
| thread_handling | one-thread-per-connection |
+—————–+—————————+

查看最大连接数

show variables like ‘%max_connections%’;
+—————–+——-+
| Variable_name | Value |
+—————–+——-+
| max_connections | 1024 |
+—————–+——-+

设置最大连接数

set global max_connections=1024

查看当前连接情况

show status like ‘Threads%’;

| Threads_cached | 2 | 缓存的当前没在用的线程数
| Threads_connected | 6 | 打开的连接数,跟show processlist看到数量相同
| Threads_created | 1119 | 创建过的总线程数
| Threads_running | 1 | 当前正在处理sql的连接数

查看详细的连接信息

show processlist;
| 1249 | root | localhost:51297 | DB1 | Sleep | 16952 | | NULL |
| 1250 | root | localhost:51334 | DB1 | Sleep | 7593 | | NULL |
| 1257 | root | localhost:53919 | DB2 | Sleep | 3397 | | NULL |
| 1259 | root | localhost:53980 | DB3 | Sleep | 626 | | NULL |
| 1260 | root | localhost:53981 | DB4 | Sleep | 553 | | NULL |
| 1264 | root | localhost | NULL | Query | 0 | NULL | show processlist

按Ip查看连接数

select SUBSTRING_INDEX(host,’:’,1) as ip , count() from information_schema.processlist group by ip order by count() desc;
+———–+———-+
| ip | count(*) |
+———–+———-+
| localhost | 6 |

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值