How do I install PostgreSQL 9.6 on any Ubuntu version?
How do I install PostgreSQL 9.6 on any Ubuntu version since it doesn't come by default with the most recent version?
Ubuntu Xenial (16.04) comes with PostgreSQL 9.5 from the default repositories.
4 Answers
For the following Ubuntu versions, you can install with the given commands, as per the official PostgreSQL Apt Repository.
Ubuntu 17.04 - 17.10
Version 9.6 comes with the distribution.
sudo apt-get install postgresql-9.6Ubuntu 14.04, 16.04
sudo add-apt-repository "deb $(lsb_release -sc)-pgdg main"
wget --quiet -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6 4 Follow below steps:
Reference is taken from this blog.
You need to add the latest PostgreSQL repository for the latest version.
sudo add-apt-repository "deb trusty-pgdg main"Update and Install PostgreSQL 9.6:
sudo apt-get update
sudo apt-get install postgresql-9.6Default postgres super user and postgres database is created. You need to set a password for the postgres super user.
ubuntu@:~$ sudo passwd postgres
Enter new UNIX password:****
Retype new UNIX password:****
passwd: password updated successfullyIf service is not started, you can start the PostgreSQL service.
sudo service postgresql startConnect PostgreSQL server using postgres user:
ubuntu@:~$ su postgres
Password:****Create a sample database:
createdb database_nameConnect to that database:
psql -d database_name 2 The accepted answer wouldn't work for me on WSL Ubuntu 18.04.
What did work for me was based on
essentially:
sudo sh -c 'echo "deb `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
wget -q -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6 postgresql-contrib-9.6I simply added -9.6 to the installed packages.
I followed this Github gist - I am running ubuntu xenial inside vagrant and wanted to upgrade existing postresql official repository vesion 9.5 to 9.6 so that I can use PostGIS extension which is served best by version 9.6 (officially mentioned in their site) Hope this helps someone.
1More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"