8 C
Texas
angeloma
Senior Writer and partner

How to install PostgreSQL 13 on Debian 10?

Hi, friends, in this post, I’ll show you how to install PostgreSQL 13 on Debian 10.

PostgreSQL 13 is the latest stable version of what is perhaps the most advanced open-source relational database manager. So many sysadmin need to have it on the different servers.

If you want to know all the news or at least the most important ones, you can read this post

PostgreSQL 13 is available

- Advertisement -

Well, PostgreSQL 13 comes with many important improvements and it’s a good time to install it. That’s what this post is about.

So let’s go for it.

Install PostgreSQL 13 on Debian

PostgreSQL is included in the official Debian repositories, but not in version 13 but in version 11.

The installation of PostgreSQL 13 is possible thanks to the repository it has for APT package managers that is used by Debian, Ubuntu, Linux Mint and derivatives.

So let’s start.

First, open a terminal session or connect to your server using SSH. Then, install some necessary packages:

:~$ sudo apt install gnupg gnupg2

At the end, the PostgreSQL 13 repository should be added to the list of Debian software sources. To do this, create the following file:

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

And in it he adds the following:

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

1.- Adding the postgresql repository
1.- Adding the postgresql repository

Then save the changes by pressing CTRL + O and close the file by pressing CTRL + X.

For the repository to be accepted by the system, you need to add the gpg key to it. To do this, use the following command:

:~$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
OK

2.- Adding the GPG key for the repository
2.- Adding the GPG key for the repository

Once the process has been completed, simply update the APT cache.

:~$ sudo apt update

You can now view all the packages related to PostgreSQL 13 by typing

:~$ sudo apt install postgresql-13

But don’t press enter, just press the TAB key and you’ll see the following:

3.- All postgresql 13 packages
3.- All postgresql 13 packages

As you can see in the image, we have PostgreSQL 13 available. So to install it run the following command:

:~$ sudo apt install postgresql-13
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following additional packages will be installed:
libgdbm-compat4 libjson-perl libllvm7 libperl5.28 libpq5 libxslt1.1 perl pgdg-keyring postgresql-client-13 postgresql-client-common postgresql-common ssl-cert
Suggested packages:
perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make libb-debug-perl liblocale-codes-perl postgresql-doc-13 openssl-blacklist
Recommended packages:
libjson-xs-perl sysstat
The following NEW packages will be installed:
libgdbm-compat4 libjson-perl libllvm7 libperl5.28 libpq5 libxslt1.1 perl pgdg-keyring postgresql-13 postgresql-client-13 postgresql-client-common postgresql-common
ssl-cert
0 upgraded, 13 newly installed, 0 to remove and 10 not upgraded.
Need to get 34.5 MB of archives.
After this operation, 145 MB of additional disk space will be used.
Do you want to continue? [Y/n]

4.- Install PostgreSQL 13 on Debian 10
4.- Install PostgreSQL 13 on Debian 10

Now we’ll see if everything went well.

Testing the installation

By default, Debian when installing PostgreSQL starts and enables the service. Therefore, it is ready to be tested. However, if you want to stop the service, you can use this command:

:~$ sudo systemctl stop postgresql

On the other hand, the best way to know if PostgreSQL is ready for work is to execute some command from the console. So we’ll access it first:

:~$ sudo -i -u postgres

Remember that the PostgreSQL console is accessed through the postgres user.

And finally, we access with this command:

:~# psql

Once inside, we can, for example, display all the databases in the system:

:~# \l

5.- All postgresql databases
5.- All postgresql databases

And so we can work without problems with PostgreSQL.

Conclusion

PostgreSQL 13 is a powerful database manager that is used in many projects worldwide. This makes many people want to have the latest stable versions to take even more advantage of the tool.

Please share this post and join our Telegram channel.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article