Saturday, January 31, 2015

CentOS 7 PostgreSQL 9.2 install

Here's what I did to install PostgreSQL on a CentOS 7 box.  As root:

yum -y install postgresql postresql-server postgresql-contrib postgresql-libs

Optionally, install pgAdmin III with:
yum -y install pgadmin3

Configure initial database structure:
postgresql-setup initdb

Configure PostgreSQL to listen on all IPs by editing /var/lib/pgsql/data/postgresql.conf.  Change listen_addresses = '*'

Start the server:
systemctl start postgresql

Check that the service is listening:
netstat -antup | grep 5432

Modify /var/lib/pgsql/data/pg_hba.conf to allow md5

## IPv4 local connections:
host    all             all             127.0.0.1/32            md5 
# IPv6 local connections:
host    all             all             ::1/128                 md5 

As the user postgres reload configuration:
su - postgres
pg_ctl reload

As postgres, create a test database and an administrative user:
createdb test
psql test
CREATE USER root WITH SUPERUSER LOGIN PASSWORD 'password';
\q

As root, configure PostgreSQL to start with the system:
systemctl enable postgresql