Search code examples
databaseprivilegesmysql-5.7

How to Lock a user's account in MySQL 5.7?


There is a new security feature of user's account locking in MySQL 5.7. Administrators can lock and unlock accounts for better control over who can log in.

I need the exact command to Lock / unlock the user's account.


Solution

  • From the MySQL Documentation, I got the answer, there is very simple command to LOCK and UNLOCK MySQL user:

    ALTER USER 'jeffrey'@'localhost' ACCOUNT LOCK;
    ALTER USER 'jeffrey'@'localhost' ACCOUNT UNLOCK;
    

    Doc Link