PostgreSQL – Initialize Database At Different Location

PostgreSQL version: 8.3

By default, the PostgreSQL database files is located at /var/lib/pgsql/data. Initialize the database can be done by the following command.

  • service postgresql initdb

So what about if i want to initialize the database at another location?
Here are the steps.

1. Login as/Switch to postgres


2. Initialize the database

  • initdb -D /home/ykyuen/data


3. Database files are created


4. Edit the postgresql startup script

  • vi /etc/rc.d/init.d/postgresql


5. Start the database

  • /etc/init.d/postgresql start

Done =)

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.