Install Postgresql 9.4 on Ubuntu 18.04

Solution 1:

Step 1: Add PostgreSQL Apt Repository

$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
$ wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -

Step 2: Install PostgreSQL

$ sudo apt-get update
$ sudo apt-get upgrade

$ sudo apt-get install postgresql postgresql-contrib libpq-dev pgadmin3

Step 3: Connecting to PostgreSQL

$ sudo su - postgres
$ psql

To list the databases type following command

postgres-# \l

credit digital ocean

Solution 2:

I had the same problem when trying to install PostgreSQL 9.4 or higher in Centos 7.

But I have found that in the PostgreSQL site they have binaries for several distros and different versions.

For Ubuntu, PostgreSQL maintains its repositories and the instructions to enable and install them can be found in: https://www.postgresql.org/download/linux/ubuntu/

In my case it was compile it or install it from there.