2

I am having a problem changing the data directory on postgresql 9.1 on ubuntu 13.04:

I first did a:

sudo pg_dropcluster --stop 9.1 main

and then attempted to create a new one in the desired path:

 sudo pg_createcluster -d /home/fccoelho/Documentos/databases/postgresqldata 9.1 main

but i fails with a permission denied:

Creating new cluster (configuration: /etc/postgresql/9.1/main, data: /home/fccoelho/Documentos/databases/postgresqldata/)...
initdb: could not access directory "/home/fccoelho/Documentos/databases/postgresqldata": Permission denied
Error: initdb failed

I should mention That I checked the permissions, tried creating the directory manually and "chowning" to user postgres afterwards, etc. nothing changed the permission denied message.

I also tried to used the initdb binary distributed with POstgresql without success

How do I make this work?

2
  • 1
    It's not just the target directory. In order to traverse the path, any directory along the path must have the "x" bit set for "others" (unless it belongs itself to postgres). Have you checked that? Commented Apr 15, 2013 at 12:24
  • Thanks, see my workaround below. It may have something to do with the x bit, but I haven't checked. Commented Apr 15, 2013 at 12:44

1 Answer 1

1

I have found a workaraound, but not really a solution:

I found out I cannot maintain the data directory within my home tree so I created a new directory /home/postgresqldata/ and ran:

sudo pg_createcluster -d /home/postgresqldata/ 9.1 main

and everything worked as expected!!

Sign up to request clarification or add additional context in comments.

1 Comment

anyways keeping postgres data in your home folder is probably not the best way... Otherwise if you need to create the data folder in your home folder, you have to check if the postgres user have execute permission on your user directory (which by default is NOT the case), so when you execute the script with sudo it probably drops privileges and tries to access the directory with the 'postgres' user as it's the default owneruid and ownergid passed to the init_db sub-routine in pg_createcluster - check the source in github

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.