Topic: Error: Unable to connect to MySQL server.

An error was encountered
Error: Unable to connect to MySQL server. MySQL reported: User [my user] has already more than 'max_user_connections' active connections.

I belive it has something to do with the coding. I've been in contact with both my hosting provider and a couple of friends, they all say it has to do with the code not closing connections after executing some stuffs, and therefore filling up the maximum users connections in mySQL. Most of you might not notice this, but when you've got a very big forum this is a pretty big consern.

Re: Error: Unable to connect to MySQL server.

No, PunBB closes all its connections (as PHP would anyway)
You didn't enable p_connect in config.php, did you?

3 (edited by Tartin 2006-08-01 11:38)

Re: Error: Unable to connect to MySQL server.

Smartys wrote:

No, PunBB closes all its connections (as PHP would anyway)
You didn't enable p_connect in config.php, did you?

$p_connect = false;

Nope... That's not the problem.

Edit: I've installed the addon Private Messages, who uses the mySQL tables to store and recieve the information. Could it be that the addon who is bad written?

Re: Error: Unable to connect to MySQL server.

No, nothing should affect that: without p_connect it can't possibly be PunBB's fault
Check your db_layer file just to be sure you're not using p_connect (it's only even possible if you're using MySQL I believe)

The only other alternative is that you have more users requesting pages at a time then connections allowed by MySQL at once, which means you should talk to your host

Re: Error: Unable to connect to MySQL server.

Smartys wrote:

No, nothing should affect that: without p_connect it can't possibly be PunBB's fault
Check your db_layer file just to be sure you're not using p_connect (it's only even possible if you're using MySQL I believe)

The only other alternative is that you have more users requesting pages at a time then connections allowed by MySQL at once, which means you should talk to your host

I've already spoken to my host, they said it is on default settings for mySQL, and have no option of changing it. I checked the dbhost folder, all I could find that had anything to do with p_connect was

    function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
    {
        $this->prefix = $db_prefix;

        if ($p_connect)
            $this->link_id = @mysql_pconnect($db_host, $db_username, $db_password);
        else
            $this->link_id = @mysql_connect($db_host, $db_username, $db_password);

It's not like it happens all the time, sometimes when 30 ppl are logged on and sometimes when 250 ppl are logged on. Doesn't make sense...

Re: Error: Unable to connect to MySQL server.

I've already spoken to my host, they said it is on default settings for mySQL

They lied. The default is 0, which is unlimited. Hosts set that variable to try and control use of their MySQL server.

And it seems like a "standard" is 20. So if there are 20 connections to MySQL (or 20 pageloads) at the same time, you'll get the error.

Do you run any other MySQL apps which might trigger this?

Re: Error: Unable to connect to MySQL server.

Smartys wrote:

I've already spoken to my host, they said it is on default settings for mySQL

They lied. The default is 0, which is unlimited. Hosts set that variable to try and control use of their MySQL server.

And it seems like a "standard" is 20. So if there are 20 connections to MySQL (or 20 pageloads) at the same time, you'll get the error.

Do you run any other MySQL apps which might trigger this?

Nope, only the forum. The host it b-one, I'll try to look more into it and ask them again.

Re: Error: Unable to connect to MySQL server.

keep in mind if you aren't paying for a dedicated server then you are sharing the server with other sites, that means you are sharing MySQL/Apache etc, which means another site can be maxing out the limit the host has set

Re: Error: Unable to connect to MySQL server.

prozente wrote:

keep in mind if you aren't paying for a dedicated server then you are sharing the server with other sites, that means you are sharing MySQL/Apache etc, which means another site can be maxing out the limit the host has set

No, that limit is per MySQL account: if he's using the same MySQL account as other people he has bigger issues tongue

Re: Error: Unable to connect to MySQL server.

Smartys wrote:
prozente wrote:

keep in mind if you aren't paying for a dedicated server then you are sharing the server with other sites, that means you are sharing MySQL/Apache etc, which means another site can be maxing out the limit the host has set

No, that limit is per MySQL account: if he's using the same MySQL account as other people he has bigger issues tongue

oops, sorry I was thinking of the max_connections option and completely forgot about the max_user_connections

so yes the host is purposely doing this and telling you otherwise

on most servers you will have read access to /etc/my.cnf unless you're chroot'd
you can try this script to see what they have the limit set to

<pre><?php
error_reporting(E_ALL);

if (!function_exists("file_get_contents")) {
    function file_get_contents($filename){
        $handle = fopen($filename, "r");
        $retval = fread($handle, filesize($filename));
        fclose($handle);
        return $retval;
    }
}

echo file_get_contents('/etc/my.cnf');

?></pre>