Saturday, January 11, 2014

Installing PostgresSQL on Ubuntu



1.Verify that you do not already have installed PostgreSQL in your machine

Run the following command in your console

ps ax | grep postgres

If you get a response similar to the one below, then you have PostgreSQL installed


Ss 0:00 postgres: writer process
Ss 0:00 postgres: wal writer process
Ss 0:00 postgres: autovacuum launcher process
Ss 0:00 postgres: stats collector process

2.Install PostgreSQL on your system

sudo apt-get update
sudo apt-get install postgresql-9.1

3.Configure your PostgreSQL Password

sudo -u postgres psql template1
ALTER USER postgres with encrypted password 'your_password';
Press ctrl-d

4.Configure MD5 Autentication

sudo nano /etc/postgresql/9.1/main/pg_hba.conf

Update the

local all postgres

Entry to

local all postgres md5

5.Enable TCP/IP connections

sudo nano /etc/postgresql/9.1/main/postgresql.conf

Locate the line

#listen_addresses = 'localhost'

and change it to

listen_addresses = 'localhost'


6.Restart the postgresql

sudo service postgresql restart

7.Create the database


create database testdb;

List available databases

\list

List users

\du >>> List Users