21

After trying apt-get install postgresql-9.4, updating, trying again etc etc. It seems I can't install it:

 Couldn't find any package by regex 'postgresql-9.4'

I know there is a similar question in askubuntu but the answer there doesn't work either.

I need postgresql version 9.4 cause I'm doing a pg:backup from Heroku and I get this error if I don't have 9.4.

Thanks a lot for your help.

  • How should we help you? You mention not even your Ubuntu version. – A.B. Jun 8 '15 at 20:46
  • 1
    The official website describes steps for adding the postgresql repository, which will then allow you to download the postresql. More info : postgresql.org/download/linux/ubuntu – Sergiy Kolodyazhnyy Jun 8 '15 at 20:47
45

This command installs the recent version for your distribution:

sudo apt-get install postgresql

postgresql-9.4 is available since Utopic.

Source

Here is a step by step guide to install Postgesql 9.4 for your Ubuntu (Utopic, Trusty, Precise, Lucid) version.

sudo add-apt-repository "deb https://apt.postgresql.org/pub/repos/apt YOUR_UBUNTU_VERSION_HERE-pgdg main" 

For trusty:

sudo add-apt-repository "deb https://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"

To get your ubuntu version:

lsb_release -sc

Now import the public key and install:

wget --quiet -O - https://postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - 
sudo apt-get update
sudo apt-get install postgresql-9.4
  • Answer improved, but what is your Ubuntu Version? – A.B. Jun 9 '15 at 3:46
  • Thanks, I voted your answer up, I'll test it in a couple of hours. I'm on Ubuntu 14.04 LTS - Trusty. – alejoss Jun 9 '15 at 16:25
  • @alejoss: As you seem to have forgotten to acept this answer: If this answer helped you, don't forget to click the grey at the left of this text, which means Yes, this answer is valid! ;-) – Fabby Aug 30 '15 at 11:03
15

Use the following commands (the command is capable of getting your Ubuntu version, No need of manual change):

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 --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.4 pgadmin3

Source: How to Install PostgreSQL 9.4 in Ubuntu / Linux Mint

  • thanks, this worked nicely. +1 for making this dynamic with 'lsb_release -cs' – Aidan Melen Mar 3 '17 at 17:38
6

You can install it by running

sudo apt-get install postgresql

Version 9.3 will be installed for 14.04, 9.4 for 14.10 and 15.04.

If you need 9.4 with Ubuntu 14.04, you can install it as described at postgresql site

0

If you want to install PostgreSQL 9.5 in Ubuntu in specific version like Ubuntu 14 then Follow the steps:

Create the file /etc/apt/sources.list.d/pgdg.list and add a line for the repository :

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"> /etc/apt/sources.list.d/pgdg.list'

Import the repository signing key, and update the package lists :

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.