Category Archives: MySQL

How do I increase MySQL’s connection limit?

First, a warning: Before you increase MySQL’s connection limit, you should try to find out why you reached the max number of connections. Most of the time, the problem is in the code. You may have to ask yourself if you really need to write a threaded script.

In case you do need to use threading in your script, do this:

MySQL’s default configuration sets the maximum simultaneous connections to 100. If you need to increase it, you can do it fairly easily:

Open /etc/my.cnf with an editor:

# vi /etc/my.cnf

Beneath the [mysqld] stanza add:

max_connections = 250

Restart MySQL afterwards and verify with:

# echo "show variables like 'max_connections';" | mysql

This will show the new value for max_connections.

A few other links to read: