Install PostgreSQL on Linux

Redhat Linux

  • Download a PostgreSQL distribution from
    • postgresql-libs-8.3.0-1PGDG.f7.i686.rpm (libraries)
    • postgresql-server-8.3.0-1PGDG.f7.i686.rpm (server)
    • postgresql-8.3.0-1PGDG.f7.i686.rpm (client)
  • To run postgres, use:
service postgresql [status|stop|start|restart]
  • The first time you run "service postgresql start", it asks you to initialize a database, run:
service postgresql initdb
  • Configuration files can be found at this path /var/lib/pgsql/data

Ubuntu Linux

sudo apt-get install postgresql-8.3
sudo apt-get install pgadmin3

(pgAdmin III is a handy GUI for PostgreSQL)

  • To run postgres, use:
/etc/init.d/postgresql [status|stop|start|restart]
  • Configuration files can be found at this path /etc/postgres/<version>/main/

PostgreSQL Configurations

  • Change postgres user password
sudo -u postgres psql template1
template1=# ALTER USER postgres WITH ENCRYPTED PASSWORD 'postgres';
template1=# \q
  • Update pg_hba.conf with something like:

Change this line:

host all all ident sameuser


host all all md5
  • Update postgresql.conf with (if you want to connect from a remote machine):

Change this line:

#listen_addresses = 'localhost'


listen_addresses = '*'

Change this line:

#password_encryption = on


password_encryption = on