Linux

How to install the latest version of Postgresql on Ubuntu

It is quite easy to install the latest version of Postgres on Ubuntu.

First, declare Postgres repository, create the file /etc/apt/sources.list.d/pgdg.list like this :

Import the repository signing key, and update ubuntu package lists

Then install latest postgresql (actually version 11) and its latest GUI pgadmin (actually version 4) :

Postgresql is now running, you can check that by pgsql client. Be careful, by default, authentification are based on linux account : only postgres user can connect to the database :

Create a user, a database and grant privileges :

The linux account myuser must exist, so do not forget to create it AND access the database with that user.

If you want to access the database mydb from any linux account, you have to edit a configuration file :

and change this line :

To this:

Then restart postgresql :

You are ready to start your project.

For those who are using python/Django, you will have to install psycopg2 package which requires postgresql dev files :

Now you just have to run migrate to create tables for Django :