MySQL 8.4Lab-verified · 2026-11-30

MySQL ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

The account's password is marked expired, so the session can log in but may not run anything until the password is changed.

MySQL 8.4.13
1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

Jump to a cause

  1. 01New account created with PASSWORD EXPIRE (must change on first login)
  2. 02Batch/app account whose password expired

Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-30 · container image mysql:8.4

ERROR 1820 means the login succeeded in a restricted mode: the password is expired (password_expired = Y in mysql.user), so every statement except changing the password is refused.

The mysql client only opens such a session with --connect-expired-password (otherwise it stops with "Please use --connect-expired-password option or invoke mysql in interactive mode"). Below are the two ways we cleared it.

01New account created with PASSWORD EXPIRE (must change on first login)

The admin created app_user with a temporary password and PASSWORD EXPIRE. Logging in worked, but SELECT * FROM orders returned ERROR 1820.

mysql.user showed password_expired = Y. In the same session the user ran ALTER USER USER() IDENTIFIED BY 'My_New_Pw_2026', got Query OK, and the following SELECT returned the row.

Setup
Setuprun as root
CREATE DATABASE shop;
CREATE TABLE shop.orders (id INT PRIMARY KEY, amount INT);
INSERT INTO shop.orders VALUES (1, 100);
CREATE USER 'app_user'@'%' IDENTIFIED BY 'Temp_Pw_2026' PASSWORD EXPIRE;
GRANT ALL ON shop.* TO 'app_user'@'%';
OUTPUT
Query OK, 1 row affected (0.01 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)
Reproducerun as app_user
$ mysql --connect-expired-password -h 127.0.0.1 -u app_user -p'Temp_Pw_2026' shop
SELECT * FROM orders;
✕ ERROR
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Checkrun as root
SELECT user, host, password_expired FROM mysql.user WHERE user = 'app_user';
OUTPUT
+----------+------+------------------+
| user     | host | password_expired |
+----------+------+------------------+
| app_user | %    | Y                |
+----------+------+------------------+
1 row in set (0.00 sec)
After the fixrun as app_user
$ mysql --connect-expired-password -h 127.0.0.1 -u app_user -p'Temp_Pw_2026' shop
ALTER USER USER() IDENTIFIED BY 'My_New_Pw_2026';
SELECT * FROM orders;
✓ SUCCESS
Query OK, 0 rows affected (0.00 sec)

+----+--------+
| id | amount |
+----+--------+
|  1 |    100 |
+----+--------+
1 row in set (0.00 sec)

02Batch/app account whose password expired

batch_user had its password expired (here with ALTER USER ... PASSWORD EXPIRE, the same state a password lifetime leaves when it runs out). Its SELECT failed with ERROR 1820, which for a batch job means every query fails.

The check showed password_expired = Y. The admin ran ALTER USER 'batch_user'@'%' IDENTIFIED BY '...' PASSWORD EXPIRE NEVER, after which password_expired = N and password_lifetime = 0. The job then logged in normally, without --connect-expired-password, and the SELECT worked.

Setup
Setuprun as root
CREATE DATABASE shop;
CREATE TABLE shop.orders (id INT PRIMARY KEY, amount INT);
INSERT INTO shop.orders VALUES (1, 100);
CREATE USER 'batch_user'@'%' IDENTIFIED BY 'Batch_Pw_2026';
GRANT SELECT ON shop.* TO 'batch_user'@'%';
ALTER USER 'batch_user'@'%' PASSWORD EXPIRE;
OUTPUT
Query OK, 1 row affected (0.00 sec)

Query OK, 0 rows affected (0.02 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)
Reproducerun as batch_user
$ mysql --connect-expired-password -h 127.0.0.1 -u batch_user -p'Batch_Pw_2026' shop
SELECT * FROM orders;
✕ ERROR
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Checkrun as root
SELECT user, host, password_expired, password_lifetime FROM mysql.user WHERE user = 'batch_user';
OUTPUT
+------------+------+------------------+-------------------+
| user       | host | password_expired | password_lifetime |
+------------+------+------------------+-------------------+
| batch_user | %    | Y                |              NULL |
+------------+------+------------------+-------------------+
1 row in set (0.00 sec)
Fixrun as root
ALTER USER 'batch_user'@'%' IDENTIFIED BY 'Batch_Pw_2026_b' PASSWORD EXPIRE NEVER;
SELECT user, host, password_expired, password_lifetime FROM mysql.user WHERE user = 'batch_user';
OUTPUT
Query OK, 0 rows affected (0.01 sec)

+------------+------+------------------+-------------------+
| user       | host | password_expired | password_lifetime |
+------------+------+------------------+-------------------+
| batch_user | %    | N                |                 0 |
+------------+------+------------------+-------------------+
1 row in set (0.00 sec)

Update the new password in the application's connection settings at the same time.

After the fixrun as batch_user
$ mysql -h 127.0.0.1 -u batch_user -p'Batch_Pw_2026_b' shop
SELECT * FROM orders;
✓ SUCCESS
+----+--------+
| id | amount |
+----+--------+
|  1 |    100 |
+----+--------+
1 row in set (0.00 sec)

FAQ

How do I change my own expired password in MySQL?

In the same session: ALTER USER USER() IDENTIFIED BY 'new_password';. In our run it returned Query OK and the next SELECT worked.

How do I stop a service account's password from expiring?

As an admin: ALTER USER 'user'@'host' PASSWORD EXPIRE NEVER; (you can combine it with IDENTIFIED BY). Our run showed password_lifetime 0 afterwards.

How do I check whether a password is expired?

SELECT user, host, password_expired, password_lifetime FROM mysql.user WHERE user = '...';. password_expired = Y means it is expired.

Why does the mysql client say Please use --connect-expired-password?

The client refuses to open a session for an expired password in batch mode. Add --connect-expired-password so you can run ALTER USER, or have an admin reset the password.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13