This tutorial will take you through how to install pgAdmin 4 on Debian 12. pgAdmin 4 is a popular graphical tool with an intuitive user interface for administering PostgreSQL databases.
Table of Contents
Installing pgAdmin 4 on Debian 12
Install PostgreSQL on Debian 12
Since pgAdmin is a graphical PostgreSQL administration tool, you need to be already running PostgreSQL.
Check the guides on the link below on how to install PostgreSQL on Linux systems.
How to install PostgreSQL on Linux
Next, you can now proceed to install pgAdmin 4 on Debian as follows;
Install pgAdmin APT Repository
Default repos do not provide pgAdmin packages. Hence, you need to install pgAdmin repository as follows;
echo \
"deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" \
> /etc/apt/sources.list.d/pgadmin4.list
Install pgAdmin Repository GPG signing Key
Install the public key for the repository using the command below;
apt install gnupg2 curl
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub \
| sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/packages-pgadmin-org.gpg
Install pgAdmin 4
Now, update system package cache and install pgAdmin on Debian 12;
apt update
pgAdmin4 is primarily a desktop application. There also exist a web based version.
Install for both desktop and web modes:
apt install pgadmin4
If you want, you can install for desktop mode only:
apt install pgadmin4-desktop
Or Install for web mode only;
apt install pgadmin4-web
Using pgAdmin Desktop Version
If you installed the desktop app version, then you should be able to launch it from the applications menu;
Launch it and give it a few to start.
Once it started, then, pgAdmin4 desktop dashboard;
Click Add New Server under the dashboard to connect to your PostgreSQL database.
Under General tab, enter the name of the connection.
Under Connections tab, set the database connection details;
- address of the database server
- port
- credentials
Save the connection.
Select the database and click SQL tab to run the queries.
Using pgAdmin Web Version
If you want to use the pgAdmin web version, run the command below to set it up.
sudo /usr/pgadmin4/bin/setup-web.sh
Go through the prompts to setup the login credentials, and setup pgAdmin web server.
Setting up pgAdmin 4 in web mode on a Debian based platform...
Creating configuration database...
NOTE: Configuring authentication for SERVER mode.
Enter the email address and password to use for the initial pgAdmin user account:
Email address: [email protected]
Password:
Retype password:
pgAdmin 4 - Application Initialisation
======================================
Creating storage and log directories...
We can now configure the Apache Web server for you. This involves enabling the wsgi module and configuring the pgAdmin 4 application to mount at /pgadmin4. Do you wish to continue (y/n)? y
The Apache web server is running and must be restarted for the pgAdmin 4 installation to complete. Continue (y/n)? y
Apache successfully restarted. You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4
You can now access your pgAdmin from the browser on the local system using the addresses provided above, http://127.0.0.1/pgadmin4.
Login and follow the same procedure as above to add the server and login to the PostgreSQL database.
Conclusion
That concludes our guide on how to install pgAdmin 4 on Debian 12. You can now administer PostgreSQL with ease.