K
K
Kizzeon2020-03-03 20:28:39
PostgreSQL
Kizzeon, 2020-03-03 20:28:39

Must be superuser or a member of the pg_write_server_files role to COPY to a file, how to decide?

When trying to copy the database to your folder:

COPY (SELECT ROW_TO_JSON(t)
FROM (SELECT * FROM item) t)
TO '/project/database';

Gives me an error:
Must be superuser or a member of the pg_write_server_files role to COPY to a file

Where is the error here and how can the above code be corrected?
Thank you in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2020-03-03
@ky0

This is not an error, but a reminder that superusers and members of the corresponding role can upload something to files. Are you sure that's what you want, and not, for example, redirecting the result of a query to a file on the client?

V
Vladimir Korotenko, 2020-03-03
@firedragon

you must be a superuser
or a member of the group
pg_write_server_files role Solved
by adding your role to this group and giving it rights to the
/project/database folder at the OS level

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question