PgAdmin is an open-source administration tool for Postgres databases. It has a graphical user interface written with the Qt application framework and uses libpq as its backend driver to communicate with the database server.
It can be used to manage local or remote PostgreSQL servers, create new databases, execute SQL queries and scripts against those databases using an interactive query editor that provides syntax highlighting and intelligent autocomplete, among other things, import data from various sources into the database or generate reports from within the program about available space in tablespaces or indexes as well as many other things.
The main reason Linux user choose PgAdmin 4 is that its UI looks very simple and modern, similar to other web apps like Google Drive. In contrast, other administration tools for PostgreSQL tend to look complex and outdated in comparison, which can be discouraging for new developers who want to learn more about databases.
- You’ll need root privileges throughout this tutorial, so run everything as root with either sudo or su.
- A server running Debian 11 or Debian 10 (Buster) with a minimum of 2GB of RAM and 15 GB of free space.
- This tutorial was tested on Debian but should work on all previous versions or other Debian-based distributions like Ubuntu and Linux Mint.
Step1: Updating the System
First, log in to your Debian server via SSH as the root user, update the system and install some necessary packages:
sudo apt update && sudo apt upgrade
This command will update the repositories and install new software packages.
Once the update is completed, we need to install some required dependencies. Such as: ca-certificates, gnupg
sudo apt-get install curl ca-certificates gnupg gnupg2 -y
These dependencies will help us compile and run PgAdmin 4. Type Y and hit Enter when prompted. The installation may take a minute or two.
Step 2: Install PostgreSQL
Because PgAdmin 4 requires the PostgreSQL server to run. So before we install pgAdmin4, we must install the PostgreSQL server first.
sudo apt-get install postgresql -y
Once the installation is complete, start the PostgreSQL service and enable it to launch automatically at system boots:
sudo systemctl start postgresql.service
sudo systemctl enable postgresql.service
Check the status of the PostgreSQL server with:
sudo systemctl status postgresql.service
If you see an output saying “active (running)”, everything is OK.
The PostgreSQL server listens to requests on TCP port 5432 by default. Run the following command to check if PostgreSQL is listening on port 5432.
ss -antpl | grep 5432
It should display an output similar to the following one.
Step 3: Installing pgAdmin 4 on Debian
The pgAdmin 3 package is shipped with Debian 10, while the pgAdmin 4 package is not. To install pgAdmin 4, we need to add the official package repository of PostgreSQL on Debian 10.
First, add the GPG key to the system using the curl command.
curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add
You should get an OK output if the key has been added successfully.
Once the key is added, add the official PostgreSQL package repository to your sources.list file in /etc/apt/sources.list using the echo command.
sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
You are now ready to install pgAdmin 4 on Debian. To install pgAdmin 4, run the following command.
sudo apt-get update sudo apt-get install pgadmin4 -y
Once the installation is done, you must run a web setup script that shipped with pgAdmin 4. This setup script lets you run pgAdmin 4 in web interface/web mode.
Run the following command to run the script.
For the pgadmin4 initial user account, you will be prompted to provide an email address and a password. Enter any username, a secure password and email address for this initial user. Once you fill in all the details, hit Enter to continue the installation.
After that, you will be asked a series of questions, type Y and hit ENTER to accept the default.
Step 4: Configuring the Firewall
If you installed pgadmin4 on a server behind a firewall or router that has a firewall enabled, you will need to open TCP Ports 80 and 443 on your firewall.
You can do this with the ufw command.
sudo ufw allow http sudo ufw allow https
Reload the firewall with the following command to all the changes take effect.
sudo ufw reload
To check the status of the firewall and your rules, run:
sudo ufw status
You should see something like this.
Step 5: Accessing the pgAdmin 4 Web Interface
Now that you have completed the installations, you can access pgAdmin 4 on your server’s IP address. To get started, open a web browser and type the URL below in the address bar.
Where: <your-servers-ip> is the actual IP address of your PostgreSQL server.
For example, to access pgAdmin 4 on 192.168.1.103, type:
If all goes well, you should see a log in page as shown below. Enter the username and password you created during installation, then click Login.
Once you are authorized, you will be taken to the pgadmin4 dashboard. From there, you can use pgAdmin 4 to manage your PostgreSQL servers and databases.
That’s it! You have successfully installed pgAdmin 4 on a Debian 10 system. For more information about pgAdmin, please visit the official pgAdmin documentation page.
In this guide, we have shown you how to install pgAdmin 4 on a Debian system. You can now use the pgAdmin graphical tool to manage your database servers from a web interface. Happy data management.