1、mysql> show status like '%connect%';
Connections,试图连接到(不管是否成功)MySQL服务器的连接数。
Max_used_connections,服务器启动后每个用户最大链接数限制。
Max_Connections 最大链接数限制
Threads_connected,当前的连接数。
Aborted_connects 尝试已经失败的MySQL服务器的连接的次数。
3、修改max_connections
在配置文件(my.cnf或my.ini)在最下面,天加一句:
max_connections=32000
然后,用命令重启:/etc/init.d/mysqld restart
虽然这里写的32000,实际MySQL服务器允许的最大连接数16384;
添加了最大允许连接数,对系统消耗增加不大。
4、mysql> show processlist;
显示当前正在执行的MySQL连接。
Aborted Clients:
The number of connections that were aborted because the client died without closing the connection properly.
当ablort clients增大的时候意味着有客户端成功建立连接,但是很快就断开连接或者被终止了,这种情况一般发生在网络不稳定的环境中。主要的可能性有
a)客户端没有主动关闭mysql连接mysql_close()。
b)wait_timeout设置很短被mysql干掉了。
c)客户端由于某些原因被干掉了。
Aborted Connection:
The number of failed attempts to connect to the MySQL server.
当有大量的链接连接不上mysql的时候,这个数值就会激增。主要的可能有:
a)没有授权或者密码不对。一般错误日志中会有如下报错(Access denied for ‘user’@‘host’)
b)连接数满了。一般报错包含(too many connections)
c)超过链接时间限制,主要有这个参数控制connect_timeout(mysql默认是10s,基本除非网络环境极端不好,一般不会超时。)