Error
Error Code: 1820

MySQL Error 1820: Mandatory Password Change

📦 MySQL
📋

Description

Error 1820 indicates that the MySQL server requires you to change your password immediately. This typically happens when your current password has expired or was set with a policy requiring a mandatory reset upon first login, preventing any further operations until the password is updated.
💬

Error Message

You must reset your password using ALTER USER statement before executing this statement.
🔍

Known Causes

3 known causes
⚠️
Password Expiration Policy
Your MySQL user password has exceeded its configured validity period, requiring a mandatory update.
⚠️
New Account First Login
The user account was recently created or reset, and the password was explicitly marked for a mandatory change on the next login.
⚠️
Administrator-Forced Reset
A database administrator has reset your password and configured it to require a change upon your next login attempt.
🛠️

Solutions

3 solutions available

1. Immediate Password Reset easy

Reset the user's password directly to bypass the mandatory change prompt.

1
Connect to your MySQL server as a user with sufficient privileges (e.g., root).
2
Execute the ALTER USER statement to reset the password for the affected user. Replace 'your_username' with the actual username and 'new_strong_password' with a secure password.
ALTER USER 'your_username'@'localhost' IDENTIFIED BY 'new_strong_password';
3
Attempt to execute your original statement again.

2. Forcing Password Expiration medium

Configure the user account to immediately require a password change upon next login.

1
Connect to your MySQL server as a user with sufficient privileges (e.g., root).
2
Use the ALTER USER statement to set the password expiration clause for the affected user. This forces the user to change their password on their next login. Replace 'your_username' with the actual username and 'current_password' with their current password.
ALTER USER 'your_username'@'localhost' PASSWORD EXPIRE;
3
Instruct the user to log in again. They will be prompted to change their password.
4
Once the user has successfully changed their password, they will be able to execute subsequent statements.

3. Disabling Mandatory Password Change (Temporary or for Specific Users) medium

Disable the password expiration policy for a specific user account. Use with caution.

1
Connect to your MySQL server as a user with sufficient privileges (e.g., root).
2
Execute the ALTER USER statement to disable password expiration for the affected user. Replace 'your_username' with the actual username. This will prevent the mandatory password change prompt.
ALTER USER 'your_username'@'localhost' NOT IDENTIFIED BY 'current_password';
-- Alternatively, if you want to keep the password but disable expiration:
ALTER USER 'your_username'@'localhost' PASSWORD EXPIRE NEVER;
3
Attempt to execute your original statement again.
🔗

Related Errors

5 related errors