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


Tip of the Day
Language: SQL
Expertise: Intermediate
Dec 20, 2019

WEBINAR:

On-Demand

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


Understanding MAX_USER_CONNECTIONS in MySQL

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.

M S Sridhar
 
Thanks for your registration, follow us on our social networks to keep up-to-date