4

I'm using Zend Freamwork for my website. And sometimes i get the following exception from my website:

Message: SQLSTATE[42000] [1203] User elibrary_books already has more than 'max_user_connections' active connections

As I know "Zend Freamwork" uses PDO to connect to the database. How i can resolve this problem?

3 Answers 3

2

Always close your connection. If you are using Sql class it looks like:

$sql->getAdapter()->getDriver()->getConnection()->disconnect();
1

Sometimes 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.

Check your settings for wait_timeout. Default value is unreasonably long. Optimal value might be around 20 seconds. You will probably also want it this low if you're using persistent connections.

2
  • How can i set "wait_timeout" for PDO?
    – Mirodil
    Commented Oct 13, 2011 at 11:38
  • You can set wait_timeout as a session variable each time you open a connection by issuing the query: SET wait_timeout=28800; If you're using PDO (a much better choice than the MySQL or MySQLi drivers), you can issue the above statement by setting a PDO::MYSQL_ATTR_INIT_COMMAND driver option when creating the PDO connection object.
    – Koba
    Commented Oct 13, 2011 at 11:51
0

Try setting the persistent flag in your database driver configuration to be false:

resources.db.params.persistent = 0
1
  • this did not help i'm getting the same message.
    – Mirodil
    Commented Oct 17, 2011 at 6:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.