Home > Uncategorized > Linux: installing postgresql and initializing a database

Linux: installing postgresql and initializing a database

Installing!!!

#yum list | grep postgresql

Then verify that you see:

postgresql.i386, postgresql-server.i386 and postgres-libs.i386. if you have 64 bit version then you will see x86_64.

Centos installation comes with postgresql-lib installed. If it is not installed then please follow:

#yum install postgresql-libs

Now, the general installation. As root install postgres core and postgresql server:

#yum install postgresql postgresql-server

We need a seperate user as owner of postgresql database owner so create postgres user:

#adduser postgres

A directory to store datafiles caleed the 'datafile' for the database:

#mkdir -p /usr/local/pgsql/data

It is necessary to change ownership of the data files to the postgres user:

#chown postgres /usr/local/pgsql/data

now change your role to postgres user from root user:

#su - postgres

Initialize the datafiles for the database:

#/usr/bin/initdb -D /usr/local/pgsql/data

In most of the cases it will starStart the database with initialized datafiles as the background process (&) and log all messages and errors (2&1) in the logfile:

#/usr/bin/postgres -D /usr/local/pgsql/data > logfile 2>&1 &

Create the test database:

#/usr/bin/createdb firstdb
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: