35.2 C
Senior Writer and partner

Two ways to install PostgreSQL on Debian 10 Buster?

To develop great applications you need a great database manager. So, that is why in this post I will teach you how to install PostgreSQL on Debian 10, Buster.


PostgreSQL is one of the most advanced and modern relational database managers out there. It is always shown as the immediate competitor of MySQL and MariaDB in the segment of open source and community database managers.

One of the main advantages of using PostgreSQL is that it has extensive documentation and supports powerful features. All this in an open-source and free application.

So, let us install PostgreSQL on Debian 10.

Getting PostgreSQL on Debian 10

- Advertisement -

To achieve our goal, we have two ways. The first and safest is to install PostgreSQL using the official Debian 10 Buster repositories. The other is to use PostgreSQL’s dedicated repository for Debian 10. So I will teach you how to install PostgreSQL using both methods.

Using the Debian 10 repositories

As I said before, this is the safest method out there. This is because Debian does numerous tests on the packages that are in the repositories. The problem is that sometimes they are not so up-to-date.

On the other hand, as time goes by, the version available in the repositories gets older and older. But as it has come out recently, this should not be a problem yet.

Note: In case you do not have Debian 10, here we show you how to install it.

So open a terminal session or connect to your server using SSH. Type the following command:

:~$ sudo apt install postgresql-11

After entering your password, the installation will begin.

Using the PostgreSQL official repository

PostgreSQL gives us an official repository where it distributes different branches of application development. For example, using the official PostgreSQL repository we can install the latest stable version or a trial version.

The main advantage of using this method is that as time goes by, we can always have the application updated. This way we will have the latest news available. In this case, the installation requires a few more steps.

First, install some necessary packages.

:~$ sudo apt install curl ca-certificates gnupg

Then, import the GPG key for the repository.

:~$ curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

1.- Add the repository GPG
1.- Add the repository GPG

The next step is to create a text file where we will add the file in question.

:~$ sudo nano /etc/apt/sources.list.d/pgdg.list

And add the following:

deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main

Save the changes and close it.

Next, refresh the ATP cache and install PostgreSQL.

:~$ sudo apt update && sudo apt install postgresql-11

2.- Install PostgreSQL on Debian 10
2.- Install PostgreSQL on Debian 10

Test PostgreSQL on Debian 10

To check that everything went well, it is necessary to enter the PostgreSQL shell and execute a command. For example, list all existing databases.

:~$ sudo -i -u postgres
:~# psql

Then, list all existing databases.

:~# \l

3.- PostgreSQL working properly
3.- PostgreSQL working properly

So, that is it.


In this post, you have learned to install PostgreSQL on Debian 10 Buster using both the official distribution and application repositories. Both cases have their advantages and are quite simple to do.

Please share this post with your friends and join our Telegram channel.

- 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