How to Fix MySQL Error 3118 (ER_ACCOUNT_HAS_BEEN_LOCKED)
You get mysql error 3118 when you try to log in with a locked database user. To fix it, an admin must manage the account or wait for the lock timer to end. The database server returns the symbol ER_ACCOUNT_HAS_BEEN_LOCKED with SQLSTATE HY000 during the login step. It tells you that access is denied because the account is locked. Your password might be right, but the server blocks the user anyway. Teams see this issue when automated scripts or users trigger account safety rules. Why mysql erro
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You get mysql error 3118 when you try to log in with a locked database user. To fix it, an admin must manage the account or wait for the lock timer to end.
The database server returns the symbol ER_ACCOUNT_HAS_BEEN_LOCKED with SQLSTATE HY000 during the login step. It tells you that access is denied because the account is locked. Your password might be right, but the server blocks the user anyway. Teams see this issue when automated scripts or users trigger account safety rules.
Why mysql error 3118 happens in your database
MySQL lets admins lock user accounts to keep data safe. There are two main ways an account gets into this state. First, a database admin can lock the user by hand during an update or audit. Teams also lock new accounts until a project goes live.
Second, the server can lock the account on its own after too many bad logins. When an app sends the wrong password several times, the server blocks the user. This rule stops attackers from guessing passwords through brute force.
Old scripts and background jobs cause this error very often. When you change a password, one old script might still use the old key. That script tries to log in over and over in a fast loop. Soon, the failed login counter hits the limit and locks everyone out. Even apps with the new password cannot log in once the user locks.
How to check the lock and fix the user
Do not fix this issue by turning off your password safety rules. Also, never give your app a root role just to bypass a lock. Instead, log in with an admin account to see why the user failed.
Check the system user table to see the current lock flag for that specific user and host. Next, read your database error logs to find which client IP sent the bad logins. You must stop the bad app or fix its stored password first. If you manage the user before fixing the app, it will lock again right away.
Cross-Account Access Delegation + MySQL Access Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Once the bad script stops, run an alter user action to manage the account. If a temporary login failure rule caused the lock, you can also wait. The timer resets on its own after the set lock days pass. Still, unlocking the user by hand gets your app back online much faster.
How to stop account lockouts in production
Shared database accounts make this error much harder to track and fix. When five apps share one login, one bad deploy breaks all five apps. Give each app and service its own database user instead. Then one bad script only locks its own account while other apps run fine.
Human users also trigger locks when they type old passwords in local tools. Moving away from static passwords for people stops this issue at the source. Short-lived credentials and central login checks keep bad password attempts away from the database. You should also mask sensitive data like emails and card numbers in query results. Masking rewrites matched fields in results so extra user accounts do not risk raw data.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.
First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.
Frequently asked questions
Does mysql error 3118 mean my password is wrong?
No, you will see this error even when you type the right password. Once an account locks, the database blocks all login attempts for that user right away.
Will a locked MySQL account manage on its own?
It depends on how the lock happened. Temporary locks from failed logins clear after the set time passes, or when the server restarts. Manual admin locks stay in place until an admin unlocks the user.
Do active database sessions drop when an account locks?
Existing sessions usually keeps the session active until the client closes them or runs a reset check. Still, the locked user cannot open any new database sessions until you clear the lock.
Related guides
In this post