Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 21, 2012, 04:04:48 AM

Pages: [1]   Go Down
  Print  
Author Topic: "Too many connections" error on the database. Where to raise the limit?  (Read 1504 times)
ASFx
Space Explorer
***
Offline Offline

Posts: 6


« on: October 31, 2005, 01:43:16 AM »

I got a "too many connections" error on my database today.  How do I raise the limit so I can make sure that doesnt happen again?  Is the option in WHM somewhere?

Thanks.
Logged
perestrelka
Administrator
Master Jedi
*****
Offline Offline

Posts: 1395



« Reply #1 on: October 31, 2005, 04:18:25 AM »

Hello,

There are a couple of things you can do to work around the connections limitation. First, you can find this error if your scripts open persistent connections, wich aren't closed even if the script terminates. Use mysql_connect() instead of mysql_pconnect() unless you have a good reason. In particular, check this setting in third-party scripts (such as osCommerce).

Next, the file /etc/my.cnf typically holds defaults for mysql. Note: You will need to login in the shell as root to make the changes.  A line of

[mysqld]
set-variable=max_connections=500

will increase the number of connections allowed to 500. This should be more than enough.  Please note that the instruction should be placed in the [mysqld] section. Otherwise MySQL will ignore it.

After resetting this, restart mysql (you would run "service mysqld restart" as root or issue the MySQL restart via WHM).

Now you should never run out of mysql connections.
Logged

Kind Regards,
Vlad Artamonov
thismobile
Space Explorer
***
Offline Offline

Posts: 8


« Reply #2 on: December 01, 2005, 04:17:14 AM »

I've got a Dedicated III package could I push the max connections higher than 500? I've got my sql driven chat script being hit by thousands of users at once and I want to allow it the maximum number of connections possible
Logged
abhilash
Intergalactic Cowboy
*****
Offline Offline

Posts: 61



« Reply #3 on: December 01, 2005, 07:21:35 AM »

It mainly depends on the RAM you have, plus many other factors..have a look into the URLs below for a bit math.

http://dev.mysql.com/books/hpmysql-excerpts/ch06.html#hpmysql-CHP-6-SECT-4.3
http://www.mkdoc.org/docs/howto/server-tuning/
Logged

Abhilash

JSA Supervisor - System Admin Team
Pages: [1]   Go Up
  Print  
 
Jump to: