How to grant pg_read_server_files role?

I’m trying to import data from .csv files, but I get this error:

must be superuser or a member of the pg_read_server_files role to COPY from a file

Then when I try granting this role with…

GRANT pg_read_server_files TO "myusername";

…I get this error:

must have admin option on role "pg_read_server_files"

Hi,

You seem to want to COPY a .csv file from your local disk into a table. The PostgreSQL COPY command that references a file (such as COPY mytable FROM "filename.csv") only works with files on the PostgreSQL server, so if you want to use your local file, you can use the psql \copy command instead.

See PostgreSQL: Documentation: 14: COPY for COPY, and PostgreSQL: Documentation: 14: psql for the psql command.

2 Likes

Thanks for the quick reply, Matthias!