Utkarsh Atri Utkarsh Atri -4 years ago 234
SQL Question

Permission Denied when trying to restore .dump file postgres

I am trying the following command load schema and data from .dump file :

psql proj1 -f /Users/utkarshatri/Desktop/proj1/mymyunsw.dump

but it says permission denied.

enter image description here

the folder containing the .dump file has read write permissions for postgres

total 101728
drwxr-xr-x@ 4 utkarshatri staff 136 24 Mar 05:41 ./
drwx------@ 23 utkarshatri staff 782 24 Mar 06:18 ../
-rwxrw-rw-@ 1 utkarshatri staff 52080321 8 Mar 00:30 mymyunsw.dump*
-rwxr--r--@ 1 utkarshatri staff 2130 8 Mar 00:30 proj1.sql*

simple cat on terminal works but returns permission denied on postgres commandline
enter image description here

How do I fix this?

Any help would be appreciated.

Answer Source

The issue seems to be not with the current directory, but the directory, one level above:

drwx------@ 23 utkarshatri staff 782      24 Mar 06:18 ../

This is showing that only your user has the permissions required to enter the project directory. Try running this

chmod a+rx ../

This will change the permissions such that anyone on the system can open and look inside the directory, but still, only you will be able to write.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download