0

I'm trying to copy a CSV file into a table by running a simple \copy command in Postgres;

postgres-# \copy solved_at FROM '/Users/funnychef/Downloads/export.csv' DELIMITER AS ',';

Every time I run the command I receive the Permission Denied error:

/Users/funnychef/Downloads/export.csv: Permission denied

The permissions on the file are wide open;

$ ls -ltr ~/Downloads/expor.csv
-rwxrwxrwx 1 funnychef  staff  145524 Jul  8 22:15 /Users/funnychef/Downloads/export.csv

I assumed that the issue was related to the _postgres user not having access to the file so I made that user the owner of the file but still receive the error.

$ ls -ltr ~/Downloads/expor.csv
-rwxrwxrwx 1 _postgres  staff  145524 Jul  8 22:15 /Users/funnychef/Downloads/export.csv

What am I missing?

4
  • Have you also checked directory permissions for Downloads or other parent directories? Also, try doing a cd to the downloads folder and then connect to psql, use only file name in copy Commented Jul 9, 2018 at 4:17
  • 1
    copy your file to /tmp and try. If it works I'll add that as an answer. Commented Jul 9, 2018 at 10:08
  • moving the file to /tmp corrected the issue. Commented Jul 9, 2018 at 17:19
  • @FunnyChef glad that it worked. Accept and upvote since it worked for you. Commented Jul 14, 2018 at 3:13

1 Answer 1

1

Copy your file to /tmp directory and read the csv. The normal settings for /tmp are 1777, which ls shows as drwxrwxrwt

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

1 Comment

I like the idea of using /tmp as an easy work-around when doing one-time loads or dumps, instead of playing with all sort of other user (database or system) or directory permissions, that may not be desirable to keep anyway.

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.