install postgres 9.4 on ubuntu 14.04-2

Install with the steps below and read the statement at the end of this answer.

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 upgrade

The PostgreSQL Global Development Group (PGDG) maintains an APT repository of PostgreSQL packages for Debian and Ubuntu located at http://apt.postgresql.org/pub/repos/apt/. We aim at building PostgreSQL server packages as well as extensions and modules packages on several Debian/Ubuntu releases for all PostgreSQL versions supported.

Currently, we support

  • Debian 6 (squeeze), 7 (wheezy), 8 (jessie) and unstable (sid) 64/32 bit (amd64/i386)
  • Ubuntu 12.04 (precise), 14.04 (trusty), 14.10 (utopic) 64/32 bit (amd64/i386)
  • PostgreSQL 8.4, 9.0, 9.1, 9.2, 9.3, 9.4
  • Server extensions such as Slony-I, various PL languages, and datatypes
  • Applications like pgadmin3, pgbouncer, and pgpool-II

Packages for older PostgreSQL versions and older Debian/Ubuntu distributions will continue to stay in the repository; updates for those will be provided on an ad-hoc basis.

Source


Below are steps to install PostgreSQL 9.4 on Ubuntu 14.04.

Reference taken from this Article:

First, check the version of Ubuntu:

lsb_release -sc

You need to add the latest PostgreSQL repository for the latest version, otherwise It will install PostgreSQL 9.3. This is for trusty version.

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

Update and Install PostgreSQL 9.4:

sudo apt-get update
sudo apt-get install postgresql-9.4

Default 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 successfully

If service is not started, you can start the PostgreSQL service.

sudo service postgresql start

Connect PostgreSQL server using postgres user:

ubuntu@:~$ su postgres
Password:****

Create a sample database:

createdb database_name

Connect to that database:

psql -d database_name