Skip to content

Instantly share code, notes, and snippets.

@refo
Last active December 13, 2021 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save refo/77d021047e12eadbf8897c1173621df2 to your computer and use it in GitHub Desktop.
Save refo/77d021047e12eadbf8897c1173621df2 to your computer and use it in GitHub Desktop.
Debian Postgres
Postgresql on Debian
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql
# /etc/postgresql/13/main/postgresql.conf
# ...
# - Connection Settings -
listen_addresses = '*'
# /etc/postgresql/13/main/pg_hba.conf
# ...
# Add:
#
# Allow from private network
host all all 10.0.0.1/24 trust
pg_ctlcluster 13 main reload
sudo -u postgres psql
CREATE DATABASE dbname;
CREATE USER username WITH ENCRYPTED PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE dbname TO username;

Update user's password

ALTER USER username WITH PASSWORD 'new-password';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment