Sunday, September 21, 2014

Change DATA directory of PostgreSQL in CentOS

You need to stop the PostgreSQL first to change the DATA directory.

service postgresql stop

Now edit the start-up script

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

Change the PGDATA and PGLOG variable to wherever you want

Create the directory and set the permissions

mkdir -p /home/data/path
chown postgres:postgres /home/data/path

Initialize the database engine

su - postgres -c "initdb -D /path/to/pgdata"

Now start the PostgreSQL

service postgresql start

If you see FAILED and Permission denied message, check SELinux mode.
stop the SELinux OR change the mode enforcing to permissive.

No comments:

Post a Comment