Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to point the PostgreSQL server to a particular non-default data directory upon startup. Right now, I have to (either manually or in a script) use pg_ctl to stop and restart the database with my /new/path/to/data.

OS is Ubuntu where the default data directory is /var/lib/postgresql/8.4/main

share|improve this question
up vote 4 down vote accepted

Open /etc/postgresql/8.4/main/postgresql.confand adjust data_directory property to your new data path and restart the server using (preffered) pg_ctlcluster 8.4 main stop/start or pg_ctl if you want in that way.

Make sure that /new/path/to/data is accessible only for postgres user:

chown postgres.postgres /new/path/to/data
chmod 700 /new/path/to/data
share|improve this answer
Note that you must move the data directory (or do a new initdb to create a new cluster) or Postgres will throw a fit... – voretaq7 May 25 '11 at 16:06
Yap, must move or copy data from previous directory to that new before server start (don't try to move or copy data if postmaster is still running using previous dir). – Grzegorz Szpetkowski May 25 '11 at 16:13
yes - stop, move, then restart. Otherwise the universe will end (Or your database will be corrupted beyond the point of repair. Not a good thing either way) – voretaq7 May 25 '11 at 16:15
What is your output from pg_lsclusters command ? – Grzegorz Szpetkowski May 26 '11 at 4:28
If you don't use SSL connections, then simply turn off ssl property in postgresql.conf. If you need SSL, then make symbolic link server.crt in data directory as server.crt -> /etc/ssl/certs/ssl-cert-snakeoil.pem. Also you need root.crt -> /etc/postgresql-common/root.crt and server.key -> /etc/ssl/private/ssl-cert-snakeoil.key as well there. – Grzegorz Szpetkowski May 26 '11 at 5:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.