How to Fix MySQL Error 1862 (ER_MUST_CHANGE_PASSWORD_LOGIN)

Published
Length
3 min read

Luis Felipe Dias

All posts

You see mysql error 1862 when a user account has an expired password. Also, the login tool cannot handle password resets on its own. To fix it, log in with an updated client and set a new key. An admin can also reset the password for the locked account. This failure uses the symbol ER_MUST_CHANGE_PASSWORD_LOGIN and returns SQLSTATE HY000. The server message tells you that your password has expired. It also states that your client must support expired passwords to log in. Why mysql error 1862

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 see mysql error 1862 when a user account has an expired password. Also, the login tool cannot handle password resets on its own. To fix it, log in with an updated client and set a new key. An admin can also reset the password for the locked account.

This failure uses the symbol ER_MUST_CHANGE_PASSWORD_LOGIN and returns SQLSTATE HY000. The server message tells you that your password has expired. It also states that your client must support expired passwords to log in.

Why mysql error 1862 happens in the database engine

Database servers let teams set an age limit on user passwords. When a password passes that age limit, the server marks it as expired. An admin can also mark an account password as expired by hand. Both actions put the account into a restricted sandbox mode upon login.

In sandbox mode, the server lets the user connect, but blocks most queries. The user must set a new password before running any normal read or write task. Still, the client app must tell the server it knows how to handle this state.

During the initial handshake, the client sends its capability flags to the server. Modern interactive tools tell the server they can handle expired password states. Older drivers, scripts, or poolers often do not send this capability flag. When the server sees an expired account without that flag, it blocks the login right away. It then drops the connection and returns mysql error 1862 to the caller.

How to diagnose and fix the failure in production

First, find out which user account triggered the error in your app logs. Check if the account belongs to a person or a background app service. Next, check the client driver version used by that specific app or tool.

If a human user sees this error, they should open a modern interactive client. When they log in, the client will ask them to set a new password. Once they set the new secret, the server clears the expired flag right away.

Application-to-Application Password Management + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

If a background app hits this error, an admin must step in. Log in to the database using an admin account with user management rights. Set a new password for the affected service account and update your secret store. Then restart or reload the app so it uses the fresh password.

Do not give the affected account admin rights just to bypass the error. Also, do not turn off password age rules across the whole database server. Instead, set a clear rotation rule that fits how each account works. Human accounts can use short password age limits and modern login tools. Service accounts should use automated secret rotation so their keys never expire mid-run.

Preventing expired password lockouts across your team

Lockouts often happen when teams share static database keys across many apps. When one shared key expires, several production services can fail at the exact same time. You can avoid this risk by changing how engineers and apps reach the database.

Start by upgrading old database drivers across all your apps and worker nodes. Modern drivers support the full handshake protocol and report clearer status messages. Next, check the password expiration state of all accounts on a regular schedule. This check lets your team rotate keys days before the server blocks them.

You can also remove personal static database passwords for your human engineers. When engineers log in through a central broker, they use their existing work login. The database holds one managed service account, while users prove their identity outside the database. You can also add data masking to rewrite emails, phone numbers, card numbers, or national IDs in query results.

Check MySQL queries and results on the wire

MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.

Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.

Frequently asked questions

What is the difference between error 1820 and mysql error 1862?

Error 1820 happens after login when your client supports expired passwords and you run a query. You see mysql error 1862 during login when your client tool cannot handle expired passwords at all.

Can I fix ER_MUST_CHANGE_PASSWORD_LOGIN without changing the password?

An admin can clear the expired flag on the user account while keeping the old key. Still, setting a fresh password is much safer and follows good security hygiene.

Why did my automated backup script fail with SQLSTATE HY000 and code 1862?

The database account used by your backup tool reached its password age limit. Because backup tools run without human input, they cannot stop and type a new password.

The query runs. The emails stay hidden.