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