[SOLVED] mysql_connect(): Too many connections
Posted 22 March 2006 - 10:45 AM
I have hosted this site on a Linux Corporate Server.
Now After every week or some time after only 2 or 3 days the site is down by showing this error
Warning: mysql_connect(): Too many connections
As I reported this problem to the server admins they are tell me that this is because there is too many open sql connection, I should optimie my database.
I already use mysql_close(); after each open connection.
Now I am very confused why this is happening, Should I change the server, will this continue to hapen after i chnage the server.
how can I fix this problem.
Posted 22 March 2006 - 12:45 PM
MySQL's maximum number of connections is 100, so if you have a lot of users and a few slow queries it's not unusual to run into this problem. You can alleviate the problem by increasing the maximum number of connections in your MySQL configuration file, identifying your slowest queries and fixing them, or decreasing the default timeout for MySQL connections in your php.ini file.
You should also make sure that your PHP application opens one and only one database connection per page load.
Posted 25 March 2006 - 11:22 AM
as i dont have access 2 the php.ini I can't change the config.
what else can I do form My end befour i chage the server.
Posted 26 March 2006 - 02:58 PM
You can also make sure that your application is only opening one PHP connection at a time. This is just program logic.. does it run mysql_connect() twice during a page load?
Posted 31 March 2006 - 09:13 AM
I have install an invision powerboard 2.1.5 forum, and it some times generate the same error of too many connections. I have no idea with using PHP and mysql, it was working fine in start but now generate this error after a day or 2 and forum again start working fine after 4-5 hours.
I have only 29 registered users so far and highest user online is only 6, i have set options like guest can't view posts before registering, no anonymous member can view post, while registration u have to enter security code.
I have seen many webmaster facing the same problem, so it may not be becuase of server, there should be some adjustement in coding i think.
I will be thankful to you, if some1 come up with an appropriate solution.
my forum link is www.zonepk.com/forum
Thanks in advance
Posted 06 April 2006 - 01:01 PM
after checking the code I fix the problem. I found that lots of php connections are left open.
but I was wondering that if a user click the stop button befour the connection close itself ???.
Posted 06 April 2006 - 03:39 PM
Posted 06 April 2006 - 03:58 PM
If you are getting "too many connections" errors, the most likely possibility is that you are opening more than one connection per page load, or some of your queries take too long, and so a few page loads at once throw you over the limit.
Posted 14 December 2006 - 03:23 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users