Changing PostgreSQL's Data Directory in Ubuntu

Posted by ryan
at 4:46 PM on Tuesday, June 06, 2006

When installing PostgreSQL on debian the install process asks you what directory you want to contain your actual table data – which is nice when you want to use a dedicated partition instead of the default /var/lib/postgresql/data. However, in Ubuntu (Dapper Drake and Breezy Badger) the install process doesn’t give you the option of changing the default directory. Here are some quick notes on how to change the data directory to an existing non-default data dir (specifically for postgresql 7.4):

  1. remove the /etc/postgresql/7.4/main/pgdata symlink
  2. create a new pgdata symlink that points to your desired data directory.
  3. Make sure the pg_hba.conf, pg_ident.conf, postgresql.conf and root.crt symlinks in the data dir point back to the originals in /etc/postgresql/7.4/main

Restart postgres and you should now be running from you desired, non-default data directory.

tags: postgresql,postgres,ubuntu

Comments

Leave a response