6 C
Texas
angeloma
Senior Writer and partner

How to install PostgreSQL 12 on Ubuntu 18.04?

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 12 on Ubuntu 18.04.

PostgreSQL

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.

And recently version 12 has been released. If you want to know more about it read our post about it.

- Advertisement -

PostgreSQL 12.0 is available

So, let us start to work.

Install PostgreSQL 12 on Ubuntu 18.04

The best way to install PostgreSQL 12 on Ubuntu 18.04 is to use the repository that PostgreSQL developers make available to us.

In addition, it is a very secure repository with good support for Ubuntu.

So, install some necessary packages.

:~$ sudo apt install curl ca-certificates gnupg

Then, download and add the GPG key from the repository to further secure the installation.

:~$ curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
1.- Downloading the GPG key for the repository
1.- Downloading the GPG key for the repository

Now, we have to add the PostgreSQL repository. To do this, create a source file in /etc/apt/sources.list.d/ and add the following:

:~$ sudo nano /etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main

Then, save the changes and close the editor.

Finally, install PostgreSQL 12 on Ubuntu 18.04 using the following command.

:~$ sudo apt update && sudo apt install postgresql-12
2.- Install PostgreSQL on Ubuntu 18.04
2.- Install PostgreSQL on Ubuntu 18.04

Now, let’s make sure everything works.

Testing the installation

Of course, there are many ways to test whether everything went well. However, so as not to lengthen the post unnecessarily, we’ll just open the PostgreSQL console and run a command.

First, we have to change to the postgres user. This user is created during installation.

:~$ sudo -i -u postgres

This user has access to the PostgreSQL console. So just access it.

:~# psql

And inside we’ll be able to execute whatever commands we want. In this case, we will be satisfied with simply listing the example databases.

:~# \l
3.- PostgreSQL 12 on Ubuntu 18.04
3.- PostgreSQL 12 on Ubuntu 18.04

This way when showing the existing databases, we will know that everything has worked.

That is it. So, you can now use the latest version of PostgreSQL on Ubuntu 18.04.

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article