PostgreSQL in Ubuntu 20

  Uncategorized

Install

sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql.service

Create User and make it able to remote connect

CREATE USER user_name WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE db_name to user_name;
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
host    db_name     user_name     0.0.0.0/0       md5
listen_addresses = '*'

Config PostgreSQL

Backup/Restore

pg_dump -h localhost -U username dbname > dbname_backup.sql
sudo -u postgres psql dbname < dbname_backup.sql