dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Understanding MAX_USER_CONNECTIONS in MySQL

Learn how to restrict the number of connections made from a user to the database.


advertisement

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


At times, you may want to restrict the number of connections made from a user to the database. This may be necessary to improve performance, reporting, etc.

MySQL supports this with the help MAX_USER_CONNECTIONS arrtibute associated with CREATE USER and ALTER USER statements.

User creation query:

CREATE USER 'root_user' IDENTIFIED BY 'root_user' WITH MAX_USER_CONNECTIONS 2;

Here, we have used MAX_USER_CONNECTIONS with a value of 2 along with the CREATE USER query. This ensures that there can be a max of only 2 connections allowed at any given point. This can also be a security feature when used appropriately.

In case you have a user already created, and you want to add this property, you can still do it using the ALTER USER command.

Please note that the syntax is combined along with the CREATE or ALTER USER queries.

 

Visit the DevX Tip Bank

 





   
Sridhar M S. is a Java developer from Bangalore, India. He holds a master's degree in Computer Science.
Thanks for your registration, follow us on our social networks to keep up-to-date