What is pgAdmin4?
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.
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.
Before going any further, log in to your Ubuntu server and type the sudo command to get the root privileges on your system.
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.
As a result, you’re ready to install the pgAdmin4 on Ubuntu 18.04.
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‘.
Now type the password for the pgAdmin4 authentication and choose ‘OK‘.
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.
Type ‘\q‘ to exit from the PostgreSQL shell.
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.
On the pgAdmin4 login page, type your email address and password, then click the ‘Login‘ button.
As a result, you will get the pgAdmin4 admin dashboard as below.
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.
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.
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.