Mysql 查看连接数,状态,最大并发数
MySQL: ERROR 1040: Too many connections”的异常情况,造成这种情况的一种原因是访问量过高,MySQL服务器抗不住,这个时候就要考虑增加从服务器分散读压力;另一种原因就是MySQL配置文件中max_connections值过小。
首先,我们来查看mysql的最大连接数:
root@hongsin-monitor-db 18:14:58 [(none)]>show variables like '%max_connections%';
+-----------------+--------+
| Variable_name | Value |
+-----------------+--------+
| max_connections | 100000 |
+-----------------+--------+
1 row in set (0.00 sec)
查看服务器响应的最大连接数:
root@hongsin-monitor-db 18:11:29 [(none)]> show global status like 'Max_used_connections';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| Max_used_connections | 139 |
+----------------------+-------+
1 row in set (0.01 sec)
可以看到服务器响应的最大连接数为139,远远低于mysql服务器允许的最大连接数值。
对于mysql服务器最大连接数值的设置范围比较理想的是:服务器响应的最大连接数值占服务器上限连接数值的比例值在10%以上,如果在10%以下,说明mysql服务器最大连接上限值设置过高.
Max_used_connections / max_connections * 100% = 139/100000 *100% ≈ 0.139%
我们可以看到占比远低于10%(因为这是本地监控测试服务器,结果值没有太大的参考意义,大家可以根据实际情况设置连接数的上限值)。
设置这个最大连接数值
方法1:
set GLOBAL max_connections=256;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%max_connections%';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 256 |
+-----------------+-------+
1 row in set (0.00 sec)
方法2:
修改mysql配置文件my.cnf,在[mysqld]段中添加或修改max_connections值:
max_connections=256
重启mysql服务即可。
Mysql5.5 mysql5.6 mysql5.7:默认的最大连接数都是151,上限为:100000
Mysql5.0版本:默认的最大连接数为100,上限为16384
Mysql 查看连接数,状态,最大并发数的更多相关文章
- Mysql 查看连接数,状态 最大并发数(赞)
Mysql 查看连接数,状态 最大并发数(赞) -- show variables like '%max_connections%'; 查看最大连接数 set global max_connect ...
- Mysql 查看连接数,状态 最大并发数 && 怎么设置才合理
show status like '%max_connections%'; ##mysql最大连接数 set global max_connections=1000 ##重新设置 show varia ...
- Mysql 查看连接数,状态 最大并发数
show status like '%max_connections%'; ##mysql最大连接数set global max_connections=1000 ##重新设置show variabl ...
- Mysql 查看连接数,状态 最大并发数,以及设置连接数
show variables like '%max_connections%'; 查看最大连接数 set global max_connections=1000 重新设置最大连接数 set-vari ...
- Mysql 查看连接数,状态及最大并发数(转载)
-- show variables like '%max_connections%'; 查看最大连接数 set global max_connections=1000 重新设置 mysql> ...
- 【转载】Mysql 查看连接数,状态
转载地址:http://blog.csdn.net/starnight_cbj/article/details/4492555 命令: show processlist; 如果是root帐号,你能看到 ...
- Mysql 查看连接数,状态
命令: show processlist; 如果是root帐号,你能看到所有用户的当前连接.如果是其它普通帐号,只能看到自己占用的连接. show processlist;只列出前100条,如果想全列 ...
- Mysql 查看连接数,状态的相关命令
命令: show processlist; 如果是root帐号,你能看到所有用户的当前连接.如果是其它普通帐号,只能看到自己占用的连接. show processlist;只列出前100条,如果想全列 ...
- mysql查看连接数排查问题
#mysql查看连接数SHOW VARIABLES LIKE '%max_connections%'; # max_connections 最大连接数 SHOW VARIABLES LIKE '%co ...
- MySQL查看连接数
MySQL查看连接数 1.查看部分连接数(数目较多时) show processlist; 2.查看所有连接数(数目较多时) show full processlist;
随机推荐
- C++中char*与wchar_t*之间的转换
http://blog.163.com/tianshi_17th/blog/static/4856418920085209414977/ 关于C++中的char*与wchar_t*这两种类型的相互转换 ...
- IntelliJ IDEA搭建SpringBoot的小Demo
首先简单介绍下Spring Boot,来自度娘百科:Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进 ...
- 使用CTE公用表表达式的递归查询(WITH AS)
公用表表达式 (CTE) 具有一个重要的优点,那就是能够引用其自身,从而创建递归 CTE.递归 CTE 是一个重复执行初始 CTE 以返回数据子集直到获取完整结果集的公用表表达式. 当某个查询引用递归 ...
- day005-异常
1. 异常概念 1.1 异常的继承体系 异常的根类:java.lang.Throwable,其下有两个子类: Java.lang.Error Java.util.Exception ...
- Windows装系统
这几天电脑频繁崩溃,自己尝试着装了几次系统,遇到一些问题.有的解决了,有的没解决.将其一一记录在这里,作为经验参考. 自己以前最常用的方式是直接通过ultraiso将IOS文件解压到到U盘,会将U盘做 ...
- AWS的登录认证。。。
Hello, I’m sorry for any concern regarding the $1.00 Authorization that you see associated with your ...
- Struts2的学习-属性驱动和模型驱动
1.新建空项目,并托管到码云 2.设立maven 3.设置pom.xml 4.建包 5.在java包里建立两个类 package com.nf.entity; public class User { ...
- March 15 2017 Week 11 Wednesday
The starting point of all achievements is desire. 成功的第一步是渴望. Only you desire for somethings, you can ...
- Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired,
Did not receive a reply. Possible causes include: the remote application did not send a reply, the m ...
- Python:IPC-Pipe与IPC-Manger
1,IPC-PIPE: 管道 pipe from multiprocessing import Process from multiprocessing import Pipe p1,p2 = Pip ...