devxlogo

Locking a User Account in MySQL

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             |+--------------------------------------+
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist