您的位置:首页 > 数据库 > MySQL

Mysql中too many connections问题

2007-10-24 10:57 447 查看
Mysql中too many connections问题的解决
关键字: mysql
使用mysql,经常碰到too many connections的报错,登录不上去,只能重新启动。通过如下的方法可以解决这个问题:

1。首先修改/etc/my.cnf文件,增加如下一行

set-variable = max_connections=500

或在启动命令中加上参数 max_connections=500
就是修改最大连接数,然后重启mysql.默认的连接数是100,太少了,所以容易出现如题错误.

2。重新启动mysql,通过show variables可以查看max_connections是否修改成功。

3。为了防止发生too many connections时候无法登录的问题,mysql manual有如下的说明:

mysqld actually allows max_connections+1 clients to connect. The extra connection is reserved for use by accounts that have the SUPER privilege. By granting the SUPER privilege to administrators and not to normal users (who should not need it), an administrator can connect to the server and use SHOW PROCESSLIST to diagnose problems even if the maximum number of unprivileged clients are connected.

因此, 必须只赋予root用户的SUPER权限,同时所有数据库连接的帐户不能赋予SUPER权限。前面说到的报错后无法登录就是由于我们的应用程序直接配置的root用户
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: