3

I know there has been a dozen times a similar question, but I could not find an answer that worked for me.

I have a Debian 9 machine, fresh from install on which I have installed a Postgresql 9.6 server. I am trying to create a new tablespace but it fails. The command :

CREATE TABLESPACE newTableSPace LOCATION '/DATA/PostgreSQL/';

Returns the following error :

ERROR: could not set permissions on directory "/DATA/PostgreSQL": Permission denied
SQL state: 42501

So, after a few basis searches, I have already checked the following points :

  • The directory /DATA/PostgreSQL exists
  • Its owner/group is postgres:postgres
  • The rights on the directory are 770
  • SELinux is apparently not installed (in Synaptic, libselinux1 is installed, but all selinux commands that I have tried returned me "command not found". Examples : selinuxenabled, setenforce 0).

I am running out of ideas.

Anybody has a suggestion ?

Darth Kangooroo
  • 372
  • 1
  • 3
  • 18

2 Answers2

5

And I just found the solution !

The problem was the permissions of the user postgres not on directory /DATA/PostgreSQL/ but on the directory /DATA, on which it had no permission at all (it belonged to the current user with rights 770).

I have changed the permissions on this folder to 775. I guess another way would be to make the user postgres belong to the group that owns the DATA folder.

Darth Kangooroo
  • 372
  • 1
  • 3
  • 18
1

Hey I just found a possible solution, the thing is that you´ll have to give everyone access to the directory you to write in.

  1. Right click in the directory ".../targetDirectory".
  2. Properties> Security> In Group /usernames click on "edit"
  3. Add another group or username, type "Everyone" and click "OK"
  4. If you need to add more permisson to this group you check the permissions and press Ok.

You could see it in this video: https://www.youtube.com/watch?v=FQzBgEFkdes

This worked for me creating tablespaces and copy files from one directory to another one.

Hope this helps.

travs15
  • 454
  • 4
  • 5