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 comment

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