2

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

5 Answers 5

1

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.

3

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

1

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.

0

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"

0

MySQL max_connections.

Default 151

https://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_max_connections

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .