In this tutorial, I will guide you through the steps to install pgAdmin 4 on both Ubuntu 22.04 Desktop and Ubuntu 22.04 Server so that you can manage your PostgreSQL databases using web-based graphical user interface.
Server Deployment: In this method of installation, the pgAdmin is installed as a web application with the help of a web server on a command line server, so that single or multiple users can access it simultaneously using a web browser. Of course, credentials are required for security.
Desktop Deployment: This type of installation is like any other software installed locally on the computer. This means you don’t require any browser to connect and access PostgreSQL but are limited to only one user who is currently logged on to the operating system. Also, for this, the user needs to have an OS that has a GUI running. You can choose this option if you are installing pgAdmin 4 on your desktop.
As usual, we need to update the system first
sudo apt update; sudo apt dist-upgrade
Now, install curl if it is not installed yet
sudo apt install curl
Add pgAdmin 4 Public GPG Key
Ubuntu 22.04 system needs to ensure the packages we will receive to install the pgAdmin 4 are from the source as issued by the developer without any alteration. Therefore, for that, we have to add the GPG key on it used to sign the packages of this tool by the pgAdmin 4 developers.
As we have discussed at the pgAdmin 4 Introduction section of this tutorial, pgAdmin can be deployed as a web application, hence, here we will show you how to install it.
sudo apt install pgadmin4-web
Now, configure the pgAdmin user account for security purposes so that any random user won’t be able to access the pgAdmin’s web interface to manage the databases. Here is the command to create a username and password for the pgAdmin user account.
Enter the email address that you want to use as a Username and password for the account. Once done, the setup will ask you to restart the Apache web server. Press Y and hit the Enter key to restart it.