feign3
asked on
PHP 'max_user_connections' error when using mysql_pconnect
I am getting the following 2 errors randomly when accessing dynamic areas of my client's site... repeatedly refreshing the page eventualy gets my request to go through:
Warning: mysql_pconnect(): User initiate_admin has already more than 'max_user_connections' active connections in /hsphere/local/home/***/** *.com/Conn ections/Ca rt.php on line 9
Fatal error: User initiate_admin has already more than 'max_user_connections' active connections in /hsphere/local/home/***/** *.com/Conn ections/Ca rt.php on line 9
My host says I have max_user_connections=20. However I am using mysql_pconnect for my connect string. I am the only one on the page right now while I'm developing it. How could I have used all 20 persistant connections? If I somehow did is there any way to close them all?
Warning: mysql_pconnect(): User initiate_admin has already more than 'max_user_connections' active connections in /hsphere/local/home/***/**
Fatal error: User initiate_admin has already more than 'max_user_connections' active connections in /hsphere/local/home/***/**
My host says I have max_user_connections=20. However I am using mysql_pconnect for my connect string. I am the only one on the page right now while I'm developing it. How could I have used all 20 persistant connections? If I somehow did is there any way to close them all?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For more information about mysql_pconnect(); see:
http://uk2.php.net/manual/en/function.mysql-pconnect.php
and for more information about mysql_connect(); see:
http://uk2.php.net/manual/en/function.mysql-connect.php
http://uk2.php.net/manual/en/function.mysql-pconnect.php
and for more information about mysql_connect(); see:
http://uk2.php.net/manual/en/function.mysql-connect.php
oh, Just a clarification in case you don't look at the links provided:
"mysql_pconnect() acts very much like mysql_connect() with two major differences.
First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.
Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect()).
This type of link is therefore called 'persistent'. ".
Hope this helps.
"mysql_pconnect() acts very much like mysql_connect() with two major differences.
First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.
Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect()).
This type of link is therefore called 'persistent'. ".
Hope this helps.
The max_user_connections can now be set for both the user and the machine level
http://dev.mysql.com/doc/refman/5.0/en/user-resources.html indicates how to view what permissions that you have for the actual user
and if you use show process list you can see all the currently active connections on your server (if you have the appropriate permissions) you could then kill the threads that you do not want open
http://dev.mysql.com/doc/refman/5.0/en/kill.html
I suspect that if you are connecting with something other than php as well - and you have connection pooling enabled then you could have more than 20 persistant connections - same thing would happen with a .net application where garbage collection was not working
generally with php the connection is closed the moment the page stops loading to this is unlikley to be the problem - however it is probably a setting at th euser leve.