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
Nov 11, 2019

WEBINAR:

On-Demand

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


Locking a User Account in MySQL

After a user has been created and is currently in use, a need might arise for the user account to be locked. MySQL provides a mechanism to alter the user properties, thereby allowing you to lock the user account.

Assuming that the user 'dboperator' was already created, we will execute the ALTER query below to lock the user.

Query:

ALTER USER dboperator ACCOUNT LOCK;

To verify, the same, use below query.

SELECT user, host, account_locked FROM mysql.user WHERE user='dboperator';

Output:

+--------------------------------------+
| user        | host  | account_locked |
+--------------------------------------+
| dboperator  | %     |  Y             |
+--------------------------------------+
M S Sridhar
 
Thanks for your registration, follow us on our social networks to keep up-to-date