Install PostgreSQL & pgAdmin4 on Ubuntu
Jun
13
2019

Install PostgreSQL & pgAdmin4 on Ubuntu
How to Install PostgreSQL 11 on Ubuntu 18.04 & 16.04 LTS

1. Enable PostgreSQL Apt Repository

Run this command in your home directory

  • sudo apt-get install wget ca-certificates
  • wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
  • sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >>
    /etc/apt/sources.list.d/pgdg.list'

2. Install PostgreSQL on Ubuntu

  • sudo apt-get update
  • sudo apt-get install postgresql postgresql-contrib

3. Connect to PostgreSQL

After installing the PostgreSQL database server, by default, it creates a user ‘postgres’ with role ‘postgres’. Also creates a system account with the same name ‘postgres’. So to connect to Postgres server, log in to your system as user postgres and connect database.

  • sudo su - postgres
  • Psql
  • Exit from sql
    • \q

Install pgAdmin4 on Ubuntu

1. sudo apt-get install pgadmin4 pgadmin4-apache2

2. Then connect to http://example.com/pgAdmin4

Ref:
https://tecadmin.net/install-postgresql-server-on-ubuntu/
https://tecadmin.net/install-pgadmin4-on-ubuntu/