Moving a postgres database location to a new path

Posted by Dark Training on October 19, 2009 tags: | linux | postgres

One question I have seen a lot when dealing with PostgreSQL is, "How do I move the physical database location?". IE from /var/lib/postgresql/8.3/main to /database/...

This is pretty easy to do starting with PostgreSQL 8.3.

# vim /etc/postgresql/8.3/main/postgresql.conf

</p>

Locate the line data_directory and change that path to your desired new path

cp /var/lib/postgresql/8.3/main/ * <stong>/new-path</strong>;chown -R postgres <strong>/new-path</strong>;chmod -R 700 <strong>/new-path</strong>;/etc/init.d/postgresql-8.3 restart

</p>

That should do it