Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql: cannot create tablespace due to permissions

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 ?

like image 238
Darth Kangooroo Avatar asked Mar 21 '26 13:03

Darth Kangooroo


1 Answers

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.

like image 131
Darth Kangooroo Avatar answered Mar 24 '26 06:03

Darth Kangooroo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!