Resolve MySQL access denied for user root localhost account is locked quickly. Our MySQL Support team is ready to assist you.
MySQL Error mysqli_real_connect HY000 3118: Root Account Locked
If you see “access denied for user ‘root’@’localhost’. Account is locked”, MySQL has locked your root account. This lock blocks your applications or scripts from connecting to the database. Usually, multiple failed login attempts or strict security settings trigger the issue. Understanding the cause and applying the right steps to fix it helps you save time, prevent downtime, and keep your database running smoothly.

What Causes the System to Lock the Root Account
Before troubleshooting, note that the root account may become locked due to several reasons:
- Too many failed login attempts: Repeated unsuccessful logins trigger automatic account locks.
- Administrative action: An administrator may intentionally lock the account for maintenance or security.
- Expired or incorrect password: Using the wrong password multiple times can lock the account.
- Security plugins or server settings: Some configurations enforce locks after unusual activity, and in rare cases you may need to review running sessions using processlist MySQL to ensure no automated script is repeatedly attempting access.
How to Identify the Issue
Check the account status directly in MySQL to confirm it is locked:
SELECT user, host, account_locked FROM mysql.user WHERE user = 'root';In that case, if the
account_locked column shows Y, the account is locked and needs to be unlocked.
Having trouble connecting to MySQL?

How to Fix the Locked Root Account
Unlocking the Account
- Open your terminal or command prompt.
- Log in to MySQL:
mysql -u root -p
- Unlock the account:
ALTER USER 'root'@'localhost' ACCOUNT UNLOCK;
- Reload privileges to apply changes:
FLUSH PRIVILEGES;After this, try connecting with your application.
Preventing Root Account Lockouts
To reduce the chances of this error:
- Use a strong and memorable root password.
- Limit root access for applications and create dedicated users with appropriate privileges.
- Monitor login attempts and review MySQL logs for unusual activity.
- Ensure scripts and applications use correct credentials consistently especially if you often need to access WAMP MySQL from the Command line for local development.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
The access denied for user root localhost account is locked error blocks MySQL access. Unlocking the account or resetting the root password restores connectivity and ensures your database runs smooth
