brite, a MVC Framework for jQuery

Postgresql: Installing Postgresql on CentOS

March 23rd, 2010 by jeremychone

Get the YUM repository

UPDATE for 9.x, Look this link: Installing Postgres 9.x with Yum

First check your latest version of the noarch.rpm at yum postgres repos

for CentOS 5, 64bit, Postgres 9.1

$ wget http://yum.pgrpms.org/9.1/redhat/rhel-5-x86_64/pgdg-centos91-9.1-4.noarch.rpm
$ rpm -ivh pgdg-centos91-9.1-4.noarch.rpm

Filter YUM postgresql

yum list | grep postgresql

If you see postgresql from other repositories besides pgdg84, then you need to exclude postgresql from coming from other repositories by following the below instructions excerpted from PostgreSQL How to Yum

  • As root, cd /etc/yum.repos.d
  • Edit distro’s .repo file:
    • On Fedora, edit fedora.repo and fedora-updates.repo, [fedora] sections
    • On CentOS, edit CentOS-Base.repo, [base] and [updates] sections.
    • On Red Hat, edit edit /etc/yum/pluginconf.d/rhnplugin.conf [main] section.

Add to the bottom of the section:

exclude=postgresql*

Yum Install

yum install postgresql-server

Init database

service postgresql initdb
# or
service postgresql-9.1 initdb

Make it autostart

chkconfig postgresql on

Create the first DBTest

su - postgres
createdb DBTest

SQL to DBTest

su - postgres
psql DBTest

All DB files are at

Root directory: /var/lib/pgsql/

Config file: /var/lib/pgsql/data/postgresql.conf

See also:

One Response to “Postgresql: Installing Postgresql on CentOS”

  1. lystor Says:

    Upgrading PostgreSQL 8.1 to 8.4 on CentOS 5.5