MySQL max_user_connections

connectiondatabaseMySQLPHP

We're releasing a site in a couple of weeks that has been developed on a local machine but now when were testing on dev server we get

MySQL error 'max_user_connections'.

We have talked to the host company (biggest in sweden) and they say that we don't close our connections properly. But the thing is that we user the EXACT same code on another host where it works. And I also added

echo "closed"; 

in the database_close function so that now in the very bottom of very page there is "closed". To me this means that we do close the connection, anyone got any idea of what could be wrong?
We connect through the PHP PDO function and closes it by setting it to 'null', all according to the manual.

Best Answer

There's soemthing about PHP in a website which means the MySQL connection thread is not thrown away even though you've torn down the socket cleanly; it still hangs around waiting for it to be reaped.

You want to look at your setting for wait_timeout. On default installs, this is insanely long. A website will only need this to be about 20 seconds. You will probably also want it this low if you're using persistent connections.