55 lines
1.4 KiB
Plaintext
55 lines
1.4 KiB
Plaintext
|
|
To reset postgresql database password
|
|
-------------------------------------
|
|
|
|
# example below uses vaultwarden as the app with db user "vaultwarden" and db name "vaultwarden"
|
|
# all commands are executed from docker shell
|
|
|
|
# stop vaultwarden
|
|
cd /opt/stacks/vaultwarden
|
|
docker compose down
|
|
|
|
# Edit pg_hba.conf
|
|
nano /mnt/data/vaultwarden/pgdata/pg_hba.conf
|
|
|
|
# at the bottom of the file, comment out "host all all all scram-sha-256" and add new line "host all all all trust"
|
|
# result should look as follows:
|
|
# -- snip --
|
|
# host all all all scram-sha-256
|
|
host all all all trust
|
|
# -- snip --
|
|
|
|
# start postgresql
|
|
cd /opt/stacks/vaultwarden
|
|
docker compose up -d postgresql
|
|
|
|
# exec into vaultwarden-postgresql-1
|
|
docker exec -it vaultwarden-postgresql-1 bash
|
|
|
|
# open psql shell
|
|
psql -U vaultwarden -d vaultwarden
|
|
|
|
# update password for "vaultwarden" user; "ALTER ROLE" should be returned
|
|
ALTER USER vaultwarden WITH PASSWORD 'new_password';
|
|
|
|
# (optional) ensure that "vaultwarden" user owns "vaultwarden" database
|
|
ALTER DATABASE vaultwarden OWNER TO vaultwarden
|
|
|
|
# quit psql shell
|
|
\q
|
|
|
|
# exit to docker shell
|
|
exit
|
|
|
|
# restore pg_hba.conf
|
|
nano /mnt/data/vaultwarden/pgdata/pg_hba.conf
|
|
|
|
# at the bottom of the file, uncomment out "host all all all scram-sha-256" and remove line "host all all all trust"
|
|
# result should look as follows:
|
|
# -- snip --
|
|
host all all all scram-sha-256
|
|
# -- snip --
|
|
|
|
# start vaultwarden
|
|
cd /opt/stacks/vaultwarden
|
|
docker compose up -d |