How to Install PostgreSQL 10.1 in Debian 9 Stretch

I will show you how to install PostgreSQL latest version on debian operating system in this article. PostgreSQL is one of the popular database management system, distinguished by its speed and reliability to maintain the data of our applications. As it says on its website: “PostgreSQL is a powerful, open source object-relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness“. This popular program has reached version 10.1 which brings with it many improvements and above all security improvements. With this new version, PostgreSQL developers want their product to continue gaining ground in the field of database management systems and face other closed source alternatives such as Oracle, DB2 or Microsoft SQL Server.

Installing PostgreSQL in Debian GNU/LINUX is not a major problem, as it is available in the main repositories, but the version that comes with it is not the last one and does not allow us to have the latest updates and security patches that are necessary to ensure data protection.

Read below article if you want to install PostgreSQL administration and development tool pgAdmin on your Debian 9 stretch server.

New Features in PostgreSQL 10

PostgreSQL improves with each version, the changes are multiple both in administration and security level. Some important new features of PostgreSQL 10.1 are:

  • Improved authentication process. Thanks to the new authentication system SCRAM-SHA-256.
  • Many bug fixes for logical replication. Users can now fine-tune replicated data to multiple database clusters and will have the ability to perform zero-time activity updates to larger future versions of PostgreSQL.
  • Declaratory partitioning of tables. This means that users no longer need to create triggers for routing data; it’s all handled by the system.
  • Improved parallel query execution.
  • Fix memory leak over the lifespan of a query when evaluating a set-returning function from the target list in a SELECT.

As has been said, there are many changes at the application level and you can consult them all here.

Install PostgreSQL 10.1 on Debian

Let’s get to work  to install PostgreSQL. We will start with Adding PostgreSQL Apt Repository.

The first thing we must do is to create a new file called pgdg.list in the following path: /etc/apt/sources. list.d/. To do this, we must be logged in as superuser. Run below command to connect using superuser.

--Connect using superuser
su

connect using superuser

As you can see in the image, we must enter the password for root access. Then we invoke the nano editor and create the file in question.

nano /etc/apt/sources.list.d/pgdg.list

We further add the below line of code:

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

Add text code to pgdg file

Press Ctrl + x to save the changes. We say yes and with this we already have the repository added to our software sources.

The next step is import the repository signing key. After updating the package lists, doing this makes our package manager recognize the repository as a reliable one. Execute below commands in your terminal window to import the repository signing key.

--import the repository signing key
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

Import Repository key

And to refresh the repository cache, just use the following command

--Update Package Lists
apt-get update 

update package list using apt-get update

We are now proceeding to install the latest version PostgreSQL 10.1 in our Debian 9 Stretch.  Write in Terminal:

--Install PostgreSQL Latest Version.
apt install postgresql-10

Install PostgreSQL

Above command will download and install the latest version of PostgreSQL on this Debian machine. Type Y and press enter to proceed with the installation. After downloading and installing the packages, we must initialize the postgreSQL service because if it is not running, it is not possible to access or connect with it. We can do it with the following command.

--Start PostgreSQL service.
systemctl start postgresql

Restart PostgreSQL Service

We verify that we can make connection with PostgreSQL:

--Connect to PostgreSQL and Verify Installed PostgreSQL version.
su postgres -c psql postgres

Connect to PostgreSQL

And that’s it. That’s all.!!!!!!!!! We already have installed the latest version of this powerful database manager.

Now we can start working, for example, we can show the existing databases in a clean installation of PostgreSQL.

Connect to PostgreSQL databases

Conclusion

Debian is a large Linux distribution and is among the most popular in the world of system administrators. Known for its high stability and flexibility, but in its main repositories it has older versions of software and in many cases this is often a big problem. However, there are external repositories that facilitate the distribution of the latest versions of these programs.

PostgreSQL in the world of database has a very high reputation that makes it compete for the throne with other free alternatives such as Mysql or SQLite. Upgrading to the latest stable version guarantees us security patches and new features focused on speed, performance is very useful if we have a large database.

I hope you have learnt how to install PostgreSQL on Debian. Please follow our Facebook page and Twitter handle to get latest updates.

Read More:

Angelo Marquez
Summary
How to Install PostgreSQL 10.1 on Debian 9 stretch?
Article Name
How to Install PostgreSQL 10.1 on Debian 9 stretch?
Description
I will show you how to install PostgreSQL latest version on debian operating system in this article. PostgreSQL is one of the popular database management system, distinguished by its speed and reliability to maintain the data of our applications.

You may also like...

2 Responses

  1. eric says:

    The file for the repo should be /etc/apt/sources.list.d/pgdg.list SOURCES is plural, not singular

Leave a Reply

Your email address will not be published. Required fields are marked *