1. Updating Debian System
sudo apt update
sudo apt upgrade
2. Add PostgreSQL Repository on Debian
sudo sh -c 'echo "deb $(lsb_release -cs)-pgdg main" (greater than symbol) /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - | sudo apt-key add -
sudo apt update
3. Install PostgreSQL 16 on Debian
sudo apt install postgresql-16
The PostgreSQL data directory /var/lib/postgresql/16/main/ contains all of the data files for the database.
4. Manage PostgreSQL Service
sudo systemctl start postgresql.service
sudo systemctl enable postgresql.service
sudo systemctl status postgresql.service
5. Verify PostgreSQL Installation
sudo su postgres
cd
Psql
6. Set Postgres User Password
\password postgres
Once you’ve set the password, exit the PostgreSQL prompt.
\q
exit
7. Install pgAdmin in Debian
curl -fsS | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg
Next, create the repository configuration file with the following command.
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] -cs) pgadmin4 main" (greater than symbol) /etc/apt/sources.list.d/pgadmin4.list && apt update'
Next, install the pgAdmin as shown.
sudo apt install pgadmin4
Afterward, you’ll have to execute a web setup script to configure the pgadmin4 for web mode operation as shown.
sudo /usr/pgadmin4/bin/setup-web.sh
Now, launch your web browser and enter the following URL to reach the pgAdmin4 login web interface.
OR