Step 1: Update and Upgrade the packages list
It is recommended to
update and upgrade the list of packages by issuing the commands mentioned
below:
sudo apt update && sudo apt upgrade
Step 2: Install PostgreSQL
The required package
resides in Debian repository so you can install it by using “apt”: install PostgreSQL by
issuing the command mentioned below:
sudo apt install postgresql postgresql-contrib
Step 3: Once
PostgreSQL is installed, you can check the status of
service by using the command given below:
sudo systemctl enable PostgreSQL
sudo systemctl start PostgreSQL
sudo systemctl status PostgreSQL
Step 4: Client to PostgreSQL change password
sudo -u
postgres psql
ALTER USER postgres WITH PASSWORD
‘123456’;
Step 4: Setting for remote client access
vi /etc/postgresql/*/main/postgresql.conf
# list any
#listen_addresses = ‘localhost’ change to listen_addresses =
‘*’
# enable password
#password_encryption
= on change to password_encryption =
on
vi /etc/postgresql/*/main/pg_hba.conf
# add any
host all all 0.0.0.0 0.0.0.0 md5
Step 5:Restart PostgreSQL
sudo systemctl restart PostgreSQL
If you
plan to connect remotely, you might also need to open the PostgreSQL TCP port
(default 5432) on your
firewall.
At this point,
PostgreSQL is running on your Ubuntu machine and is ready to use!