简体   繁体   English

MySQL允许使用的最大连接数-编码错误?

[英]MySQL Maximum Connections Allowed Used - Coding Error?

I have recently had a problem with our website. 我最近在我们的网站上遇到了问题。 Users/visitors were being denied a connection to the database. 用户/访问者被拒绝与数据库的连接。 When I tried to log on via PHPMyAdmin and it came back with this message: "#1203 - User already has more than 'max_user_connections' active connections." 当我尝试通过PHPMyAdmin登录时,它返回以下消息:“#1203-用户已具有多个'max_user_connections'活动连接。”

It is a shared host, and the maximum connections allowed is 20, apparently. 它是一个共享主机,显然允许的最大连接数为20。 I cant change this, but the site doesnt usually have more than 20 on at any one time, and the error showed up for about an hour or two. 我无法更改此设置,但是该站点通常一次都不会打开20个以上的错误,并且错误显示了大约一两个小时。

When I asked the host what the problem is, all the sent back was this: "We are afraid this has something to do with poor scripts and was filling all of your allotted connections to the database (20). You need to check the scripts and data assets you are trying to return". 当我问主机问题是什么时,所有返回的信息是:“我们担心这与不良的脚本有关,并且正在填充所有分配给数据库的连接(20)。您需要检查脚本和您要退还的数据资产”。

What does this mean exactly? 这到底是什么意思?

This is a typical piece of code I am using: 这是我正在使用的典型代码:

session_start();
require 'include.php';
mysql_connect($DBhost,$DBuser,$DBpass);
mysql_select_db("$DBName");

I know the information here doesnt give much in the way of specific scripts, but I am wondering if there is a problem with the connection not being closed? 我知道这里的信息并不能提供特定脚本的功能,但是我想知道连接是否存在问题? Any one with any ideas would be of great help and I could look at this. 任何有任何想法的人都会有很大的帮助,我可以看看这一点。 Is there any coding errors that can cause this? 是否有任何编码错误会导致这种情况? As shouldnt the connection automatically close after the page has loaded? 页面加载后,连接不应该自动关闭吗?

Thank you in advance 先感谢您

To find out how many current connections there are, you can click on STATUS and then the SERVER tab under Runtime Information in PHPMYADMIN. 要查找当前有多少连接,可以单击STATUS,然后单击PHPMYADMIN中“运行时信息”下的“服务器”选项卡。 Or run: 或运行:

mysqladmin -uroot -ppassword processlist (from command line)

Tell your host you want to limit connections from localhost only. 告诉主机您只想限制来自localhost的连接。 I suspect you are getting probed from the Internet. 我怀疑您正在通过Internet进行调查。 The processlist command will tell you if that's the case. 如果是这种情况,processlist命令将告诉您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM