PostgreSQL

How to Install pgAdmin4 on Ubuntu 18.04

What is pgAdmin4?

pgAdmin is one of the most popular tools for managing PostgreSQL database. It was a feature-rich PostgreSQL administration tool. A complete rewrite from the previous pgAdmin version, built with Python and JavaScript.

The pgAdmin4 designed for multiple PostgreSQL versions supports for PostgreSQL 9.2 and above. Multiplatform that can run on Linux, Mac, and Windows. Also, it provides multiple deployment models, you can deploy as a single Desktop application, or deploy as a web-based application.

In this tutorial, you will learn how to install pgAdmin4 on Ubuntu 18.04 Server. You will deploy the pgAdmin4 as a web-based administration tool, accessible from anywhere and at any time through the web browser.

Prerequisites

For this tutorial, make sure you have got the PostgreSQL database installed on Ubuntu 18.04 server. Also, you will need the root privileges.

Below is the tutorial about the PostgreSQL installation on Ubuntu 18.04 server.

Install PostgreSQL on Ubuntu 18.04 Server

Before going any further, log in to your Ubuntu server and type the sudo command to get the root privileges on your system.

sudo su

Step 1 – Add pgAdmin4 Key and Repository

For this tutorial, you’re going to install the pgAdmin4 from the official PostgreSQL repository. So, you will add the pgAdmin4 key and repository to the Ubuntu server.

First, install some additional packages using the apt command below.

apt install curl ca-certificates gnupg

Now add the pgAdmin4 key to the Ubuntu system.

curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Then add the pgAdmin4 repository for Ubuntu 18.04 Bionic Beever.

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

After that, update all repository list using the apt command below.

apt update

As a result, you’re ready to install the pgAdmin4 on Ubuntu 18.04.

Add pgAdmin4 Key and Repository

Step 2 – Install pgAdmin on Ubuntu Server

Install pgAdmin4 packages with additional packages for Apache UwsGI application using the apt command below.

apt install pgadmin4 pgadmin4-common pgadmin4-apache2

During the installation, you will be asked for the configuration of the pgAdmin email and password. It will be used for the pgAdmin4 authentication.

Type your email address and choose ‘OK‘.

Install pgAdmin4 on Ubuntu 18.04

Now type the password for the pgAdmin4 authentication and choose ‘OK‘.

Setup Password for pgAdmin4

As a result, you’ve installed the pgAdmin4 on the Ubuntu 18.04 Server.

Step 3 – Setup PostgreSQL Authentication

In this step, you will change the default password for the ‘postgres’ user on the PostgreSQL database.Reference

Log in to the PostgreSQL shell using the ‘psql’ command below.

sudo -i -u postgres psql

Now change the password for the ‘postgres’ user using the following query.

\password postgres

Type ‘\q‘ to exit from the PostgreSQL shell.

Change postgres Password

As a result, you’ve changed the password for default user ‘postgres’, and you’re ready to set up the pgAdmin4 with the PostgreSQL.

Step 4 – Login to pgAdmin4

Open your web browser and type the server IP address following by the ‘pgadmin4’ path URL.

http://10.5.5.35/pgadmin4/

On the pgAdmin4 login page, type your email address and password, then click the ‘Login‘ button.

pgAdmin4 Login Page

As a result, you will get the pgAdmin4 admin dashboard as below.

pgAdmin4 Admin Dashboard

Step 5 – pgAdmin4 Connect to PostgreSQL Database

Once you’ve logged in to the pgAdmin4 dashboard, add a new PostgreSQL server.

On the pgAdmin4 dashboard, click the ‘Add New Server‘ menu.

In the ‘General‘ section, type the name of the connection. Then move to the ‘Connection‘ section and type your details PostgreSQL server.

Connect to PostgreSQL database from pgAdmin4

Click the ‘Save‘ button to add the new PostgreSQL server.

The pgAdmin4 will be automatically connected to the PostgreSQL server. Once it’s complete, you will get details PostgreSQL as below.

Connect to PostgreSQL Server

As a result, you’ve been added a new PostgreSQL server to the pgAdmin4.

Finally, you’ve successfully installed the pgAdmin4 on the Ubuntu 18.04 Server. Also, you’ve successfully changed the default password for the ‘postgres’ user, and you’ve been added new PostgreSQL to the pgAdmin4.

Write A Comment