Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to limit the number of concurrent connections to one MySQL database, regardless of which user is connecting to it?

share|improve this question
add comment

5 Answers

up vote 1 down vote accepted

No, this is not possible.
You can limit the connection one user can have or globally limit the overall connections one instance will accept.
You cannot limit connections to one specific database regardless of the user.

share|improve this answer
add comment

In /etc/my.cnf (by default) under the [mysqld] section, you can add/edit the following:

max_connections = 500 

This will allow 501 users to connect. 500 normal connections and 1 reserved connection for a super-user. This will limit the total number of connection to the whole mysql server.

If you want to limit the number of users that can use a single db, move it to a separate mysql-installation. This will give you some more overhead.

More info on how to do this, can be found here: mySQL Multiple Servers Documentation

share|improve this answer
add comment

You can use the max_connections system variable. More information here.

After re-reading your question, it looks that you want to limit the number of connections to one specific database. Unfortunately this is not possible, but you can grant permissions to only one user to access this database and limit its connections - yes, it's just a workaround, but in my opinion it's the best option in your case. Here is more information how to limit user's resources.

share|improve this answer
add comment

https://dev.mysql.com/tech-resources/articles/mysql-administrator-best-practices.html

"Set max_connections to the number of concurrent connections you need. The default value is only 100 connections, which is very small."

So, yes you can set "max_connections"

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.