# Forgotten password (/en/docs/operations/password-reset)

Recover the built-in administrator by clearing its password hash and restarting to get the factory password back; reset other users' passwords from the admin console.

## Built-in administrator forgot the password [#built-in-administrator-forgot-the-password]

Passwords are stored as argon2id hashes and cannot be written by hand. The built-in administrator's factory password, however, is seeded at startup: **if the built-in administrator has no password**, startup sets it to the factory password `imgyoung123` and marks it as requiring a change. Clearing its `password_hash` and restarting therefore brings you back to the first sign-in.

There is no dedicated reset command: one SQL statement does the job. This path requires a shell on the server or access to the database, which means control of the machine, so it is not a remote attack surface.

The built-in administrator's ID in the `users` table is always `default`. Its username can be changed in the admin console, so the commands below select it by ID rather than by name.

<Callout type="warn">
From the restart until you change the password, anyone can sign in with the public factory password and change it before you do. Sign in and change it right after the restart.
</Callout>

<Tabs items={['Binary', 'Docker', 'Compose', 'systemd']}>
<Tab value="Binary">

Requires `sqlite3` on the machine. Stop the `imgyoung` process, then run this against the database in the data directory (`data/` under the directory you start it from, or the directory set by `IMGYOUNG_DATA_DIR`):

```bash title="Terminal"
sqlite3 data/imgyoung.db "UPDATE users SET password_hash = '' WHERE id = 'default';"
```

Then start `imgyoung` again.

</Tab>
<Tab value="Docker">

The image has neither a shell nor `sqlite3`, so run a throwaway Alpine container on the same volume, and hand the database files back to the image's runtime user afterwards:

```bash title="Terminal"
docker stop imgyoung
docker run --rm -i --volumes-from imgyoung alpine:3.24 sh -c \
  'apk add -q sqlite && sqlite3 /data/imgyoung.db && chown 65532:65532 /data/imgyoung.db*' <<'SQL'
UPDATE users SET password_hash = '' WHERE id = 'default';
SQL
docker start imgyoung
```

Replace `imgyoung` with your container name.

</Tab>
<Tab value="Compose">

From the directory containing `compose.yaml`:

```bash title="Terminal"
docker compose stop imgyoung
docker run --rm -i --volumes-from "$(docker compose ps -a -q imgyoung)" alpine:3.24 sh -c \
  'apk add -q sqlite && sqlite3 /data/imgyoung.db && chown 65532:65532 /data/imgyoung.db*' <<'SQL'
UPDATE users SET password_hash = '' WHERE id = 'default';
SQL
docker compose start imgyoung
```

</Tab>
<Tab value="systemd">

The data directory is `/var/lib/imgyoung`; requires `sqlite3` on the machine:

```bash title="Terminal"
sudo systemctl stop imgyoung
sudo sqlite3 /var/lib/imgyoung/imgyoung.db "UPDATE users SET password_hash = '' WHERE id = 'default';"
sudo systemctl start imgyoung
```

</Tab>
</Tabs>

The log line `已初始化默认管理员密码,请登录后立即在后台修改` means the password was seeded. Sign in with the built-in administrator's username (`admin` unless you renamed it) and `imgyoung123`; you land directly on **Set the admin password**, and after changing it you sign in again with the new password.

The password change is enforced by the server: until the factory password is changed, that session can only sign out, read its own account (`GET /api/admin/me`) and change the password; every other admin API returns 403 `须先修改出厂默认密码` ("the factory default password must be changed first"), scripts calling the API directly included.

This only works for the built-in administrator. Clearing another user's `password_hash` just makes that account unable to sign in; no password is restored.

## Resetting another user's password [#resetting-another-users-password]

Administrators can reset any user's password in the admin console, including another administrator's: on **Users**, open the action menu at the end of the user's row (**More actions**), choose **Reset password**, and enter a new password of at least 8 characters.

- The reset takes effect immediately and ends all of that user's sessions; they sign in again with the new password.
- The user is not required to change a reset password after signing in.
- Each reset writes an audit entry (action `user.update`, detail `password.reset`).

Users who still know their old password can change it themselves with **Change password** in the account menu in the sidebar. For the API, see the [API reference](../api/admin-users.mdx).
