user3062459
user3062459

Reputation: 1631

PGAdmin to CSV error

I tried to export PGAdmin table (Students) to csv using the following query:

Copy (Select * From public."Students") To '/Users/dar/Desktop/postgs2sqlserver.csv' With CSV;

and I got the following error:

ERROR: could not open file "/Users/dar/Desktop/postgs2sqlserver.csv" for writing: Permission denied SQL state: 42501

Upvotes: 0

Views: 461

Answers (1)

Y. Leonce Eyog
Y. Leonce Eyog

Reputation: 903

When you do a "copy", the file is created with the perms of the user running the PostgreSQL process, postgres.

You can change that file's perms to allow the user to write to it, or choose a directory that the server user already has rights to.

You may try like this in Linux to change the file owner:-

chown user file
chown user directory
chown -R user directory 

to give write permisions:-

chmod a+w file
chmod -R a+w directory

Upvotes: 1

Related Questions