Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a beginner learning how to load data and I can't figure out why I can't load this data into postgres. I am using postgres 8.4 on MAC OS.

copy tname from '/Users/Shared/folder/file.cxv' DELIMITERS ',' CSV;

ERROR: could not open file "/Users/Shared/folder/file.csv" for reading: Permission denied.

I checked and have reading/writing privileges for this file.

share|improve this question

closed as too localized by dezso, Max Vernon, Mark Storey-Smith, RolandoMySQLDBA, Marian Apr 15 '13 at 18:53

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Is the file world readable, and are the directory permissions correct to enable the postgres user to read the file? – Phil Feb 12 '13 at 19:54
I'm not sure how to check directory permissions. The file is readable. – user1657563 Feb 12 '13 at 22:40
The same way you check file permissions... – Phil Feb 12 '13 at 22:45
-rw-r--r-- 1 Tim Tim 988650610 Feb 12 14:08 cts.20130208.csv I also checked the directory permissions. – user1657563 Feb 12 '13 at 23:42
Well, what is your file name after all? This latter ls output refers to what? What do you get running ls -ld /Users/Shared/folder? – dezso Feb 13 '13 at 8:39

in general, you should use \copy where you can in psql instead of COPY since that wraps COPY FROM STDIN. Where you want to copy from a file, you can wrap that yourself in your own application (specifics dependent on language but see the Pg docs).

The alternative is to put files somewhere that the Postgres user can access them, like /tmp/ and COPY from there. Of course this means the files must be present on whatever system the db server is running on, rather than the system the client is running on if using the previous paragraph's methods. Chances are your problem is either the immediate directory the file is in or a parent directory. Keeping these in a spool directory which is more general will help manage this problem.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.