Tuesday, March 12, 2013

PostgreSQL installation in Ubuntu 12.04

PostgreSQL is a powerful and reliable object-relational database system. It’s a great alternative for MySQL. It is as easy to set up, performs better and offers far more features.

1. Make sure you already have install python-software-properties
$sudo apt-get install python-software-properties

2.Add PPA repository to my Ubuntu.
$sudo add-apt-repository ppa:pitti/postgresql

3. After adding PPA, update your system apt:
$sudo apt-get update

4.Finally install postgresql-9.1:
$sudo apt-get install postgresql
if you having any error, make sure you already install libpq-dev.The libpq-dev package is for compiling wrappers/clients against libpq.

$sudo apt-get install postgresql-9.1 libpq-dev
5.Now check it out installation is successful or…..

$ locate postgresql
6. If done!!!, Cheers …………..                      Check the install version.

$psql -V
7.Now let’s take look to postgres console

$su postgres

7(a) Setup Root User ‘posrgres’
$sudo passwd postgres
 
give the postgres user a (unix) password,Now we can switch to the user postgres using command 
 
$ su postgres 
 
8. create user
     create user <username> with password '<password>';
   to create user as super user run this
     alter user <username> superuser;
   now quite from postgres console by
     \q

9. now restart your postgres
     $sudo service postgresql restart