Access denied for user ‘test’@’localhost’. Account is locked in MySQL

Lock and unlock the account in MySQL

Check the user is locked:

select host,user,account_locked from mysql.`user` where user = 'test'


host     |user|account_locked|
---------+----+--------------+
localhost|test|Y             |

Unlock the user with the following command:

ALTER USER 'test'@'localhost' ACCOUNT UNLOCK;

Verify it again:

select host,user,account_locked from mysql.`user` where user = 'test'

host     |user|account_locked|
---------+----+--------------+
localhost|test|N             |

Test the connection again. hopefully, it will be fixed.

To lock the user:

ALTER USER 'test'@'localhost' ACCOUNT LOCK;

Leave a Reply