How to change effective psql user?

I use psql to run a simple set of COPY instructions contained in a file:

psql -d mydb -f 'wbf_queries.data.sql'

where it wbf_queries.data.sqlcontains the lines:

copy <my_query> to '/home/gvkv/mydata' delimiter ',' null '';
...

but I get permission denied:

... ERROR: could not open file ... for writing: Permission denied

I connect to my user account (gvkv), which is also the superuser in PostgreSQL. Obviously psql is running under a different (efficient) user, but I don't know how to change this. Can this be done in psql or do I need some kind of unix-fu?


UPDATE: according to araqnid's answer, here is the relevant information for everyone who comes:

\copy ...

(). , SQL COPY, , psql . , , , SQL.

.

+3
1

- root UNIX . ( : copy to '/home/gvkv/mydata', postgres ( postgres/pgdba/whatever), psql ( )).

, , client-side\copy : i.e.:

\copy <copy-source> to '/home/gvkv/mydata' delimiter ',' null ''

psql "COPY TO STDOUT", /home/gvkv/mydata. , , , .

+4

Source: https://habr.com/ru/post/1744319/


All Articles