> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/error-codes/mariadb-error-codes-1800-to-1899/e1820.md).

# Error 1820: You must SET PASSWORD before executing this statement

| Error Code | SQLSTATE | Error                      | Description                                           |
| ---------- | -------- | -------------------------- | ----------------------------------------------------- |
| 1820       | HY000    | ER\_MUST\_CHANGE\_PASSWORD | You must SET PASSWORD before executing this statement |

## Possible Causes and Solutions

The password of the account has [expired](/docs/server/security/user-account-management/user-password-expiry.md), and the session runs in sandbox mode. A password expires when an administrator runs `ALTER USER … PASSWORD EXPIRE`, or when it is older than its lifetime, set with `PASSWORD EXPIRE INTERVAL` or [default\_password\_lifetime](/docs/server/server-management/variables-and-modes/server-system-variables.md#default_password_lifetime).

In sandbox mode, the server accepts only `SET` statements, including [SET PASSWORD](/docs/server/reference/sql-statements/account-management-sql-statements/set-password.md), and prepared-statement commands. Every other statement, `ALTER USER` included, fails with this error:

```
SELECT 1;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
```

To solve the error, set a new password in the same session. The session then works normally:

```sql
SET PASSWORD = PASSWORD('new_password');
```

An administrator can also set a new password for the account with `ALTER USER`, or remove the expiry with `ALTER USER … PASSWORD EXPIRE NEVER`.

Whether a client with an expired password gets a sandbox session at all depends on [disconnect\_on\_expired\_password](/docs/server/server-management/variables-and-modes/server-system-variables.md#disconnect_on_expired_password). When it's on, a client that doesn't support sandbox mode is refused at login with [error 1862](/docs/server/reference/error-codes/mariadb-error-codes-1800-to-1899/e1862.md).

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}
