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

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

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 https://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

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

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

To check login information, run the command below.

postgres-# conninfo

Installation of PgAdmin4

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

$ sudo apt-get install pgadmin4 pgadmin4-apache2

Output

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

Next, you will be prompted for your password. Provide your preferred password. The system will then proceed to wrap up the installation of PgAdmin4.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

https://IP-address/pgAdmin4

In our example, the URL is:

https://38.76.11.34/pgAdmin4

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.

By admin

Leave a Reply

%d bloggers like this: