32 C
Senior Writer and partner

Install PostgreSQL on Debian 11

Hello, friends. Although MariaDB is one of the most important database drivers out there, many large projects prefer to use PostgreSQL. So, taking advantage that we have Debian 11, I will show you how to install PostgreSQL on this system.

For the PostgreSQL website and listening to many programmers, “PostgreSQL is The World’s Most Advanced Open Source Relational Database”.

This is due to its high reliability and the way it works with data. It is said that for really big projects, there is nothing like using PostgreSQL. Also, it includes tools like multi version and others that make it very powerful.

According to the official information that we can find on the web site

PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.

- Advertisement -

So, let’s go for it.

Install PostgreSQL on Debian 11

Debian, which is a multipurpose operating system, has many different tools in its official repositories. So it is not surprising that PostgreSQL is also present.

In addition to the base PostgreSQL package there are also others that we can use at other times. If you want to do a search in the repositories run

sudo apt update
sudo apt search postgresql

And this way we will be able to see all these packages.

To install PostgreSQL on Debian 11, you have to run the following command

sudo apt install postgresql-13
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  git-man liberror-perl
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libllvm11 libpq5 libxslt1.1 libz3-4 postgresql-client-13 postgresql-client-common postgresql-common ssl-cert
Suggested packages:
  postgresql-doc-13 libjson-perl
Recommended packages:
The following NEW packages will be installed:
  libllvm11 libpq5 libxslt1.1 libz3-4 postgresql-13 postgresql-client-13 postgresql-client-common postgresql-common ssl-cert
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 42.3 MB of archives.
After this operation, 165 MB of additional disk space will be used.
Do you want to continue? [Y/n]
1.- PostgreSQL installed on Debian 11
1.- PostgreSQL installed on Debian 11

This will install the PostgreSQL base package which will be enough to do a job with it.

In Debian when installing an application that is managed through a systemd service, it will start automatically.

So, you can check the status of this service like this

sudo systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited) since Wed 2021-08-18 22:27:21 CEST; 4min 40s ago
   Main PID: 11736 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 2277)
     Memory: 0B
        CPU: 0
     CGroup: /system.slice/postgresql.service

So PostgreSQL is working properly. If you want to stop, restart or start the service you can use these commands

sudo systemctl stop postgresql
sudo systemctl restart postgresql
sudo systemctl start postgresql

Now let’s connect to PostgreSQL

Test the PostgreSQL installation

Now it’s time to use some PostgreSQL. The console is called psql but it is only available to the postgres user that was created during the installation.

So, first switch to the postgres user.

sudo -i -u postgres

And now if you access the console


Inside it, you can execute commands. For example, list the databases:

2.- Testing PostgreSQL
2.- Testing PostgreSQL

So, PostgreSQL is installed correctly and is working.

Enjoy it


In this post, you have learned how to install PostgreSQL in a quick and easy way that can help newbies get started with this powerful database manager.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"


Please enter your comment!
Please enter your name here

Latest article