postgresql

tldr; install PostgreSQL on Ubuntu 22.04/24.04 or Fedora Linux.

Ubuntu

Install

Install PostgreSQL and start the command line tool psql.

sudo apt update
sudo apt install postgresql
sudo -u postgres psql

Firewall

If you have a firewall enabled you will need to permit traffic.

sudo ufw allow postgresql

Fedora

Install

sudo dnf install postgresql-server postgresql-contrib
sudo systemctl enable postgresql
sudo postgresql-setup --initdb --unit postgresql
sudo systemctl start postgresql
sudo -u postgres psql

configuration

By default, only connections from the local system are allowed. To enable all other computers to connect to your PostgreSQL server, edit the file /etc/postgresql/*/main/postgresql.conf. Locate the line: #listen_addresses = ‘localhost’ and change it to *:

listen_addresses = '*'

After configuring the password, edit the file /etc/postgresql/*/main/pg_hba.conf to use scram-sha-256 authentication with the postgres user, allowed for all databases, from any network connection

# TYPE  DATABASE USER CIDR-ADDRESS  METHOD
host    all      all  0.0.0.0/0     scram-sha-256

Enable sql account for postgres user.

ALTER USER postgres WITH PASSWORD 'your_new_password';

References