mysql 提示 Too many connections ( 1040 )解决方法

Windows:

到c:\windows目录下(windows 2000下为winnt),找到my.ini文件打开后。

在my.ini文件中[mysqld]下添加
set-variable = max_connections= 10000

然后Save modification 保存修改。
最后把mysql重新启动一次即可。

Linux:

使用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用户

posted @ 2010-06-30 11:08  潜龙9527  阅读(587)  评论(0编辑  收藏  举报