MySQL参数max_connections分析

max_connections 是指整个mysql服务器的最大连接数;

max_user_connections 是指每个数据库用户的最大连接数,比如:虚拟主机可以用这个参数控制每个虚拟主机用户的数据库最大连接数;(历史最大连接数

 例如 GRANT USAGE ON *.* TO 'batchjob1'@'localhost' WITH MAX_USER_CONNECTIONS 10;

mysql> show variables like 'max_connections%';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
1 row in set (0.01 sec)

max_connections 值默认为151,

mysql> show status like 'max_used_connections%';
+---------------------------+---------------------+
| Variable_name | Value |
+---------------------------+---------------------+
| Max_used_connections | 5 |
| Max_used_connections_time | 2021-04-19 14:09:43 |
+---------------------------+---------------------+

max_used_connections / max_connections * 100% (理想值≈ 85%) 

如果max_used_connections跟max_connections相同 那么就是max_connections设置过低或者超过服务器负载上限了,低于10%则设置过大。

Threads_connected 跟show processlist结果相同,表示当前连接数(当前最大连接数)。准确的来说,Threads_running是代表当前并发数(当前并发数

mysql> show status like 'Threads%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_cached | 6 |
| Threads_connected | 1 |
| Threads_created | 7 |
| Threads_running | 1 |
+-------------------+-------+
4 rows in set (0.00 sec)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值