Common SQL Errors

MySQL Error 1862: ER_MUST_CHANGE_PASSWORD_LOGIN - Fix Expired Password Login Requirement

Galaxy Team
August 8, 2025

Error 1862 means the user password is expired and MySQL forces a change before the session can start.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error ER_MUST_CHANGE_PASSWORD_LOGIN (code 1862)?

ER_MUST_CHANGE_PASSWORD_LOGIN (MySQL error 1862) appears when the account password has expired. MySQL blocks the session until the user changes the password with ALTER USER or SET PASSWORD. Logging in with a supported client and resetting the password resolves the issue.

Error Highlights

Typical Error Message

ER_MUST_CHANGE_PASSWORD_LOGIN

Error Type

Authentication Error

Language

MySQL

Symbol

using a client that supports expired passwords. ER_MUST_CHANGE_PASSWORD_LOGIN was added in 5.7.1.

Error Code

1862

SQL State

HY000

Explanation

Table of Contents

What is MySQL error ER_MUST_CHANGE_PASSWORD_LOGIN (code 1862)?

MySQL throws ER_MUST_CHANGE_PASSWORD_LOGIN when an account whose password has reached its expiration policy tries to start a session. The server refuses authentication until the password is updated.

The error first appeared in MySQL 5.7.1 and only surfaces when the client library understands the expired-password protocol. Modern versions of mysql, MySQL Shell, and API connectors all trigger it.

What Causes This Error?

The built-in password expiration mechanism marks accounts as expired after a defined number of days. When such an account connects, MySQL sets the password_expired flag and returns error 1862.

Administrators can also expire a password manually with ALTER USER ... PASSWORD EXPIRE, which forces the next login to change the credential.

How to Fix ER_MUST_CHANGE_PASSWORD_LOGIN

Connect with a privileged account or the same account using the --connect-expired-password option, then run ALTER USER or SET PASSWORD to assign a new secure password.

After the password is changed, reconnect normally. The error disappears because the password_expired flag is cleared.

Common Scenarios and Solutions

Automated scripts that reuse a service account may suddenly fail when the password ages past the default 360-day policy. Updating the password in both MySQL and the script restores service.

Developers cloning production data to staging often copy user tables, including expiration flags. Clearing the flag or resetting the password in the staging environment resolves the unexpected lockout.

Best Practices to Avoid This Error

Set a predictable PASSWORD EXPIRE INTERVAL and rotate passwords in advance. Monitor accounts where password_expired = 'Y' to catch issues before they block logins.

Use Galaxy collections to store and share the ALTER USER scripts your team relies on, ensuring every engineer can reset credentials quickly from the editor.

Related Errors and Solutions

ER_PASSWORD_EXPIRE enforces a password change during the session instead of blocking login. ER_ACCESS_DENIED_ERROR appears when authentication fails for reasons other than expiration. Their fixes differ in that only error 1862 needs a direct password reset.

Common Causes

Default Password Rotation Policy

MySQL 5.7+ sets default_password_lifetime to 360 days. After that period, the server marks the password as expired.

Manual Expiration by Administrator

DBAs often run ALTER USER ... PASSWORD EXPIRE to force a credential change, immediately triggering error 1862 on next login.

Cloned or Restored Databases

Dump and restore operations copy the mysql.user table, including password_expired flags, causing surprise expirations in new environments.

Related Errors

ER_PASSWORD_EXPIRE

Prompts for an in-session password change instead of blocking login entirely.

ER_ACCESS_DENIED_ERROR

General authentication failure when credentials are wrong or host is not allowed.

ER_PLUGIN_IS_NOT_LOADED

Raised when MySQL cannot load the authentication plugin required by the account.

FAQs

Can I disable password expiration globally?

Yes. Set the global variable default_password_lifetime = 0 and restart or persist it to disable automatic expiration.

Why does my script suddenly fail overnight?

The service account password likely hit its expiration threshold. Reset the password and update the script configuration.

How do I reset another user’s expired password?

Log in as a user with ALTER USER privilege, then run ALTER USER 'target'@'host' IDENTIFIED BY 'NewPwd';

Does Galaxy help prevent this error?

Galaxy lets teams store vetted ALTER USER statements in shared collections, making it easy for engineers to rotate credentials before they expire.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo