Install PostgreSQL 11 and PgAdmin4 on Ubuntu 18.04

Filed Under: Ubuntu

In this guide, you will learn how to install PostgreSQL 11 and PgAdmin4 on Ubuntu 18.04 LTS.

PostgreSQL

PostgreSQL is a free and open source cross-platform Relational Database Management System (RDBMS). It is widely used by developers in the development environment and in production environments as well. PostgreSQL 11 was released in November 2018 and comes with a wealth of new and exciting features.

PgAdmin

PgAdmin 4 is a free and open source web-based administration and development platform that helps users to administer, manage and monitor Postgres databases in a graphical manner. Let’s now dive in and see how we can install the two.

Install PostgreSQL on Ubuntu

Step 1: Importing GPG key & adding PostgreSQL APT repository

To get started, begin by importing the GPG key for the PostgreSQL packages. Use the command below to download the CA certificates.

$ sudo apt install wget ca-certificates

Sample Output

Install Wget Ca Certificates

Next, run the command below to import the GPG key to your system.

$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Output

Add Key Ubuntu

Step 2: Adding PostgreSQL apt repository to System

Once done with importing the GPG key, append the PostgreSQL apt repository on your system.

$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'

Step 3: Installing PostgreSQL 11 on Ubuntu

Before installing PostgreSQL 11, first, update the system repositories as shown.

$ sudo apt-get update

Next, run this command to install PostgreSQL 11.

$ sudo apt-get install postgresql postgresql-contrib

Output

Install PostgreSQL on Ubuntu

Step 4: Connecting to PostgreSQL 11

By default, PostgreSQL database server creates a user ‘postgres‘ having the role ‘postgres‘.

To connect to the PostgreSQL 11 server, log in to your system and run the command below to change to the postgres user.

$ sudo su - postgres

Postgres User Created

NOTE: The ‘postgres’ user’s password is disabled by default.

Finally , to connect to the PostgreSQL 11 database server use the psql command as shown.

psql

Output

Psql command

To check login information, run the command below.

postgres-# \conninfo

Output

PostgreSQL Connection Info

Installation of PgAdmin4

To begin the installation of PgAdmin4, run the command below.

$ sudo apt-get install pgadmin4 pgadmin4-apache2

Output

Install Pgadmin4

During the installation process, you will be prompted for an email address as shown below. This is the email address you will use to log in to the PgAdmin4 interface.
Provide an email address of your choice

Pg4admin User Email

Next, you will be prompted for your password. Provide your preferred password. The system will then proceed to wrap up the installation of PgAdmin4.

Pgadmin4 Provide Initial Password
Great ! At this point you have successfully installed PgAdmin4.

Connecting to PgAdmin4

Now that we have successfully installed PgAdmin4, it’s time now to connect to it. Open your browser and browse your server’s IP address as shown

http://IP-address/pgAdmin4

In our example, the URL is:

http://38.76.11.34/pgAdmin4

Pgadmin4 Login Page

You will see the following login page. Enter the email address and password that you provided during the setup of PgAdmin4 and hit ‘Login’.

You will finally be presented with the PgAdmin4 dashboard as shown below.

Pgadmin4 Dashboard

With the dashboard, you can now create database server instances as well as monitor the performance of your databases.

This wraps up the topic of how to install PostgreSQL 11 and PgAdmin4 on Ubuntu server. Feel free to reach out to us with your feedback and share the article on your social platforms.

Comments

  1. Brent WG says:

    Hi: Quick question. Do I need to have PostgreSQL server installed on my workstation, in order to install pgAdmin4? The reason I ask is that I only want to use it to connect to remote databases. I have no intention of running a database server on my workstation. Please advise. Thanks very much for these instructions.

    Regards,
    Brent.

    1. Pankaj says:

      No, I don’t think so. You can install pgAdmin4 without installing PostgreSQL.

  2. Юрий says:

    Many thanks for this article. It’s the best article for me. Good luck! 🙂

  3. Jorge Bautista says:

    Hi, I think there’s a typo on Step 3. Instead of sudo apt-update is sudo apt-get update

    1. Pankaj says:

      Thanks for noticing it, I have fixed it.

    2. Liyakhat Ali says:

      What’s the diff b/w apt and apt-get ??

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages