Postgresql changing data directory in ubuntu

15,175

The latest log file full path is /var/log/postgresql/postgresql-8.4-main.log but the symbolic link is not the more integrated/easy way to change the data location.

I'd suggest to do it by creating the entire cluster to the desired location, with the pg_createcluster command that comes with the debian/ubuntu postgres packages.

1- delete your current cluster, if it does not contain any prior data:

$ sudo pg_dropcluster --stop 8.4 main

2- create a new cluster at the new location

$ sudo pg_createcluster -d /path/to/new/location 8.4 main

3- restart postgresql

$ sudo /etc/init.d/postgresql start
Share:
15,175
Amitash
Author by

Amitash

Updated on June 07, 2022

Comments

  • Amitash
    Amitash almost 2 years

    Possible Duplicate:
    Postgresql failed to start

    This problem has been driving me crazy and nothing seems to be working. I need to change the location where postgresql stores the data base. I am a complete novice when it comes to using commands in the terminal and step by step instructions with the proper commands would really help. I searched all over the web but all instructions assume some prior good knowledge to terminal commands. I did try one approach by creating a symbolic link in the main data folder to my required location. This gives me an error that asks me to check the log file. However, I have no idea where the log file is. A lot of people seem to have this problem and a step by step solution would surely help. My Psql version is 8.4. Ubuntu 10.10