How to give file read permission to user postgres ?

Hi, all !

I try to use the “COPY” instruction in a postgresql database to import a csv file into a table :

COPY table FROM ‘/home/XXXXXX/YYYYYYY/test.csv’ WITH CSV;

(XXXXXXX is the domain name, YYYYYYYY is a directory)

but I get “permission denied”, even if the permissions of file test.csv are -rw-r–r-- (world readable ?)

I tried to add user “postgres” in XXXXXXX group, www-data group, but “permission denied” again.

Does anybody knows ho to give reading permission to the user postgres to certain files/directories ?

Thanks for any hint !

Fred

Howdy,

Well, the issue may not just the file, but also the directory it’s in. If any of the directories under it prevent group access to them, that could cause what you’re seeing.

Would it be possible to put test.csv into /tmp? That would be an easy way to get around that issue :slight_smile:

-Eric