MySQL Database Connections

How many connection mysql database will allow in single username?

If I’m understanding your question correctly, you want to know how many connections you can make to your database with the same account credentials. That’s not an easy question to answer as there are a number of factors:

  1. What is the max_connections variable set to? I’m looking at a server with a value of 151
  2. Does your user have SUPER privileges?
  3. Have any limitations been imposed on the account

So, my server is set to 151 max_connections. That means that 151 standard users can connect. However, there will be one additional connection allowed for a user with SUPER privileges, so technically the answer is 152. There’s no reason why all 152 couldn’t be the same SUPER user (or the other 151 could be the same standard user). max_connections is always “number of normal users + 1 super user” so that if there’s a problem that a super can get in and fix it. For this reason, don’t use users with SUPER privileges in your application.

MySQL also allows you to define limitations on a user account, however. You can limit the number of queries per hour, updates per hour, connections per hour and even simultaneous connections. If you user is limited then this value will apply, as long as there are spare connections available. It depends on your configuration.