Search code examples
postgresql

Postgres ERROR: could not open file for reading: Permission denied


Computer: Mac OS X, version 10.8 Database: Postgres

Trying to import csv file into postgres.

pg> copy items_ordered from '/users/darchcruise/desktop/items_ordered.csv' with CSV;
ERROR:  could not open file "/users/darchcruise/desktop/items_ordered.csv" for reading: Permission denied

Then I tried

$> chown postgres /users/darchcruise/desktop/items_ordered.csv
chown: /users/darchcruise/desktop/items_ordered.csv: Operation not permitted

Lastly, I tried

$> ls -l
-rw-r--r--  1 darchcruise  staff      1016 Oct 18 21:04 items_ordered.csv

Any help is much appreciated!


Solution

  • chmod a+rX /users/darchcruise/ /users/darchcruise/desktop /users/darchcruise/desktop/items_ordered.csv
    

    This will change access rights for your folder. Note that everyone will be able to read your file. You can't use chown being a user without administrative rights. Also consider learning umask to ease creation of shared files.