Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql changing data directory in ubuntu [duplicate]

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

like image 974
Amitash Avatar asked Jul 23 '12 07:07

Amitash


People also ask

Where is PostgreSQL data directory Ubuntu?

PostgreSQL configuration files are stored in the /etc/postgresql/<version>/main directory. For example, if you install PostgreSQL 12, the configuration files are stored in the /etc/postgresql/12/main directory.


1 Answers

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
like image 143
Daniel Vérité Avatar answered Sep 28 '22 19:09

Daniel Vérité