mysql出现“Too many connections”的错误
- 查看mysql的状态
查看mysql设置的最大连接数
show variables like "max_connections";
查看mysql响应的最大连接数
show global status like "Max_used_connections";
mysql设置的最大连接数理想值是,响应的最大连接数占设置的最大连接数的10%以上,公式为:Max_used_connections/max_connections*100%
mysql无论如何都会保留一个用于管理员登录的连接,进行数据维护,即使当前连接数已经达到了max_connections。因此mysql的实际最大连接数为max_connections+1。
max_connections最大为16384,超过也以16384为准。
- 更改mysql设置的最大连接数,修改my.ini文件。
# 允许最大连接数
max_connections=1000