Lunarpages Web Hosting Forum

Author Topic: "Too many connections" error on the database. Where to raise the limit?  (Read 2717 times)

Offline ASFx

  • Space Explorer
  • ***
  • Posts: 6
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.

Offline perestrelka

  • Master Jedi
  • *****
  • Posts: 1397
Re: "Too many connections" error on the database. Where to raise the limit?
« 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.
Kind Regards,
Vlad Artamonov

Offline thismobile

  • Space Explorer
  • ***
  • Posts: 8
Re: "Too many connections" error on the database. Where to raise the limit?
« 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

Offline abhilash

  • Intergalactic Cowboy
  • *****
  • Posts: 61
Re: "Too many connections" error on the database. Where to raise the limit?
« 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/
Abhilash

JSA Supervisor - System Admin Team