Threads
References
Docker Cheatsheet:
# Stop and delete container
docker rm -f container-name
# Enter the container using psql
docker exec -it lab-pg17 psql -U postgres
# Build the docker image
docker build -t image-name .
# Create new container
docker run --name lab-pg17 \
-v /path/to/postgres-data:/var/lib/postgresql/data \
-e POSTGRES_PASSWORD=secret \
-p 5433:5432 \
-d lab-pg17
Meta commands
\conninfo -- show connection's info
\d -- list tables/relations
\db -- list tablespaces
\du -- list users
\dx -- list extensions
\l -- show databases
PostgreSQL config files:
show hba_file; -- pg_hba.conf
show config_file; -- postgresql.conf
Reload without restarting when changing something that loads at the start:
select pg_reload_conf();
See user passwords:
select * from pg_shadow;
Change a user's password
ALTER USER amree WITH PASSWORD 'password';
\password user
See the current password encryption (md5
or scram-sha-256
)
show password_encryption;