How to Install PostgreSQL on Debian 11 / Debian 10 | Holhol24


PostgreSQL (regularly abbreviated as Postgres) is an object-relational database control gadget (ORDBMS) emphasizing extensibility and requirements compliance.

It has greater than 30 years of lively building and a confirmed structure that has earned it a powerful recognition for reliability, knowledge integrity, and function.

PostgreSQL is launched underneath the PostgreSQL License and is to be had for Linux, Microsoft Windows, FreeBSD, OpenBSD, and macOS.

In this submit, we can see learn how to set up PostgreSQL on Debian 11 / Debian 10.

Add PostgreSQL repository

PostgreSQL publishes applications for Debian working gadget thru their devoted repository, and the applications of their repository are brisker than the ones to be had within the OS repository.

First, replace the repository index the use of the apt command

sudo apt replace

Then, set up the HTTPS reinforce for apt to get applications from the web.

sudo apt set up -y curl apt-transport-https

Now, import the PostgreSQL signing key.

# Debian 11

curl -fsSL | sudo gpg --dearmor -o /usr/percentage/keyrings/postgresql-keyring.gpg

# Debian 10

curl -fsSL | sudo apt-key upload -

Finally, upload the PostgreSQL repository knowledge to the gadget with the under command.

# Debian 11

echo "deb [signed-by=/usr/share/keyrings/postgresql-keyring.gpg] bullseye-pgdg main" | sudo tee /and so forth/apt/resources.record.d/postgresql.record

# Debian 10

echo "deb buster-pgdg main" | sudo tee /and so forth/apt/resources.record.d/postgresql.record

Install PostgreSQL on Debian

Once you’ve gotten added the PostgreSQL repository, run the next command to replace the repository index.

sudo apt replace

Then, set up PostgreSQL the use of the under command in line with the PostgreSQL model you wish to have to put in.

# PostgreSQL 13

sudo apt set up -y postgresql-13

# PostgreSQL 12

sudo apt set up -y postgresql-12

By now, the PostgreSQL provider shall be up and operating. You can test the standing of the provider with the under command.

sudo systemctl standing postgresql


 postgresql.provider - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/gadget/postgresql.provider; enabled; supplier preset: enabled)
   Active: lively (exited) since Wed 2021-09-15 14:19:30 CDT; 42s in the past
 Main PID: 3759 (code=exited, standing=0/SUCCESS)
    Tasks: 0 (restrict: 2343)
   Memory: 0B
   CGroup: /gadget.slice/postgresql.provider

Sep 15 14:19:30 debian.holhol24.native systemd[1]: Starting PostgreSQL RDBMS...
Sep 15 14:19:30 debian.holhol24.native systemd[1]: Started PostgreSQL RDBMS.

Configure PostgreSQL Server

By default, PostgreSQL listens at the localhost ( which you would possibly not at all times need as exterior programs would possibly want to connect with the database. So, we can configure PostgreSQL to hear the gadget IP deal with.

# PostgreSQL 13

sudo nano /and so forth/postgresql/13/major/postgresql.conf

# PostgreSQL 12

sudo nano /and so forth/postgresql/12/major/postgresql.conf

Set the listen_addresses to * or .

listen_addresses = ''

Restart PostgreSQL provider.

sudo systemctl restart postgresql

You can now use the netstat command to substantiate if PostgreSQL listening on port 5432 or now not.

sudo netstat -antup | grep 5432


tcp        0      0*               LISTEN      5265/postgres

READ: netstat command now not discovered on Debian – Quick Fix

Access PostgreSQL

To set up the PostgreSQL database, it is important to log in as a postgres (Linux consumer) after which must get entry to the database shell the use of the psql command.

sudo -u postgres psql


postgres@server:~$ psql
psql (13.4 (Debian 13.4-1.pgdg100+1))
Type "help" for lend a hand.


On psql shell, run the under command to modify the postgres consumer (Database admin password.

postgres=# password


postgres=# password postgres


That’s All. I am hoping you’ve gotten discovered learn how to set up PostgreSQL on Debian 11 / Debian 10.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More