0

I'm on a GCE instance with a postgresql DB and I'm running the following command:

COPY (Select * from mytable) TO '/home/myuser/myfile.txt' DELIMITER '#' CSV HEADER;

and getting the following error:

could not open file "/home/myuser/myfile.txt" for writing: Permission denied

how to fix it? (on my local machine this command works fine)

4
  • 1
    Did you search for it before ask this very popular question ? Commented May 16, 2015 at 10:08
  • @Houari yes I did, as well as read some of the answers here. I also worked around it by creating the file using nano and changing the chmod to 777 but the reason I'm asking is because there must be a better way to do it Commented May 16, 2015 at 10:40
  • In most of the case, a directory is created and used for copying to it from postgresql. with that way, you have to fix the permission problem only one time to this folder. Please look at this Commented May 16, 2015 at 10:50
  • It looks like you probably want \copy not COPY. This is a FAQ. Commented May 17, 2015 at 0:19

0

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.