Install PostgreSQL on Ubuntu server
Install PostgreSQL
sudo apt update
sudo apt install postgresql postgresql-client
Check PostgreSQL version
psql --version
sudo nano /etc/postgresql/14/main/postgresql.conf #check version folder
listen_addresses = '*'
Create template
sudo -u postgres psql template1
ALTER USER postgres with encrypted password 'password';
sudo nano /etc/postgresql/14/main/pg_hba.conf
#add line with LAN subnet
hostssl template1 postgres 0.0.0.0/0 scram-sha-256
#or
#allow all to all
host all all 0.0.0.0/0 md5
sudo systemctl restart postgresql
Check connection to db
psql --host 10.0.0.144 --username postgres --password --dbname template1
Create new database with user
sudo -u postgres psql
CREATE DATABASE db;
CREATE USER usr WITH ENCRYPTED PASSWORD '123';
GRANT ALL PRIVILEGES ON DATABASE db TO usr;