pgAdmin is a powerful and feature-rich administration tool with a user-friendly web-based interface. It’s a database management tool for one of the most popular open-source RDMB systems, PostgreSQL.
pgAdmin is used by new and experienced Postgres users, with pgAdmin features like Query Tool, ERD Tool for designing and documenting schemas, Monitoring dashboard, and other features. In this tutorial, we will show you how to install pgAdmin 4 on a Debian 11 server.
Prerequisites
- A Debian 11 VPS
- Access to the root user account (or access to an admin account with root privileges)
Table of Contents
Step 1: Log in to the Server & Update the Server OS Packages
First, log in to your Debian 11 server via SSH as the root user:
ssh root@IP_Address -p Port_number
apt-get update -y
Step 2: Install PostgreSQL
Before installing pgAdmin4, the PostgreSQL server must be installed on your server. If not installed, you can install it using the following command:
# apt-get install postgresql
You can check if PostgreSQL has been installed and running with the systemctl status command:
# systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor pr>
Active: active (exited) since Tue 2023-06-20 15:33:18 CDT; 2min 56s ago
Main PID: 2786 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 4148)
Memory: 0B
CPU: 0
CGroup: /system.slice/postgresql.service
You can enable PostgreSQL to start with every system reboot using the command:
systemctl enable postgresql
Step 3: Create a PostgreSQL Database and User
Next, you can connect to the PostgreSQL shell and create a new database and new user:
# su - postgres
# psql
Once you are connected, to create a user called dbuser with a given password, you can use the following command:
postgres= CREATE USER dbuser WITH PASSWORD 'password';
Now you can also create a new database:
postgres= CREATE DATABASE pgdb;
Next, grant all the privileges to the PostgreSQL database with the following command:
postgres= GRANT ALL PRIVILEGES ON DATABASE pgdb to pguser;
Next, exit from the PostgreSQL shell with the following command:
postgres= \q
exit
Step 4. Install pgAdmin 4
By default, pgAdmin4 is not included in the Debian 11 default repository. So you will need to add the pgAdmin4 repository in APT.
echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/bullseye pgadmin4 main"\
| sudo tee /etc/apt/sources.list.d/pgadmin4.list
Import the GPG key of the pgAdmin repository using the following command:
curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add
After that, update apt, and you can install pgAdmin using the following commands below:
sudo apt update
sudo apt install pgadmin4-web
Step 4. Configure pgAdmin.
Now we set up pgAdmin 4 before accessing it:
sudo /usr/pgadmin4/bin/setup-web.sh
You will be asked to provide your Email and password to finish the configuration as shown below:
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: test@test.com
Password: your-password
Retype password: your-passwdord
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 << Type y and press Enter
The Apache web server is running and must be restarted for the pgAdmin 4 installation to complete. Continue (y/n)? y << Type y and press Enter
Apache successfully restarted. You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin
When the installation is completed, you can open http://YOUR-IP-ADDRESS/pgadmin on your favorite browser and sign in to pgAdmin 4.
Congratulation! You have successfully installed pgAdmin 4 on Debian 11, and now you can start using it, then build and customize it.
If you are one of our web hosting customers and use our managed Linux Hosting, you don’t have to follow this tutorial and install pgAdmin 4 on Debian 11 yourself; our Linux admins will install and configure a pgAdmin 4 on your VPS for you. They are available 24×7 and will take care of your request immediately, and all you need to do is to submit a ticket; you can count on our support team.
PS. If you liked this post, please share it with your friends on social networks or simply leave a reply below. Thanks.