Handling with Mysql Error: Too many connections

May 14th, 2008 | By admin | Category: Mysql

If you have a popular website, you may have come across with this annoying error.

Mysql Error: Too many connections

This is annoying because, it only appears in high volume traffic hours. Even if you don’t see this error, your users might come across with this. Getting this error may even differ from time to time.

Here is the solution:

On apache’s “my.cnf” configuration file, you must have had something like this:

[mysqld]
port = 3306
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-locking
set-variable = max_connections=100
set-variable = key_buffer=16M
set-variable = myisam_sort_buffer_size=64M
set-variable = join_buffer=1M
set-variable = record_buffer=1M
set-variable = sort_buffer=2M
set-variable = table_cache=1024
set-variable = thread_cache_size=256
set-variable = wait_timeout=9600
set-variable = connect_timeout=10
set-variable = max_allowed_packet=16M
set-variable = max_connect_errors=10

Change max_connections to something higher. If you don’t have that line on your my.cnf file, your server must have used max_connections=100 by default. So add that line under [mysqld] with a higher value to overcome this problem.

Now you shouldn’t have a too many connections problem. Enjoy.

Tags:

Leave Comment