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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.