Forum Moderators: coopster
Warning: mysql_connect(): Too many connections in /home/httpd/vhosts/example.com/httpdocs/connect.php on line 2
Too many connections
Can ANYONE please tell me whats happenned and how to fix it?
[edited by: jatar_k at 4:38 pm (utc) on Sep. 21, 2005]
[edit reason] no urls [/edit]
From a database techie perspective, there are some standard practices.
This general database advice may help you.
Use your database admin tools to:
1) Check if the mysql server is running - if it isn't get it running
2) Close all connections, if you can
3) Stop and restart the mysqlserver if you can't drop the connections
In the future, review your code
4) Check that your PHP code and any other tools always close connections - many database servers require this, and it is good practice.
it is what the error message says: the database cannot accept more connections, all connection slots are in use otherwise. Several things to check:
-- is your own application OK? Does your application open persistent connections, which aren't closed? Use mysql_connect() instead of mysql_pconnect() unless you have a good reason to do so.
-- have you got more users then ever?
-- can you increase the max_connections system variable, or has it been increased up to its end already (its default value is 100)?
-- Have you looked in the manual for further details:
[dev.mysql.com...]
If it is your own server, then you can look into these things and try to fix and correct.
If you are on shared hosting, you need your hoster to fix this -- perhaps other shared hosting customers started to eat up more connections than they should ... (common hosting error: too many customers on one box ...).
Regards,
R.
sometimes a server problem can cause the same error, mysql maxes out and then silently dies but apache doesn't know and mysql can't release connections because it is having a little "rest". Usually restarting mysql and apache fixes it.
take a look at Romeo's recommendations
the other thing is to ask your host if you have a set limit, just so you know.
Check that your PHP code and any other tools always close connections
I've hit this problem on my server, and it has always proved to be a hardware problem, exacerbated by one of the MySQL default settings (wait_timeout which, from memory, is 28,800 secs!) (that means that all blocked threads hang around for hours before they die). There are 3 defaults which are worth changing globally:
# foll to prevent continuous new-thread spawning
# added by Alex 17 Oct 2003
interactive_timeout = 30
thread_cache = 8
wait_timeout = 30
The hardware problems, btw, were bad memory (causing DB corruption) then, later, a full partition.