Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql Permission denied for Copy from on Windows

Tags:

postgresql

I am running postgresql with pgAdmin4 on windows x64. I just created a database, then a table and now I want to add data to the table from an excel sheet using

copy table from 'C:\Users\username\Desktop\copy.csv' delimiter ',' csv header;

I get this error message:

ERROR: could not open file "C:\Users\username\Desktop\copy.csv" for reading: Permission denied HINT: COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy. SQL state: 42501

I tried running it as admin but it didn't help. Side note: pgadmin 4 opens on my Firefox browser with high privacy settings in case it has anything to do with it.

like image 392
Aslan Avatar asked Dec 06 '25 03:12

Aslan


1 Answers

For people who are still having this issue, one of the fastest workarounds I found (that sidesteps permission changes) is to use the "Users\Public" folder when reading or writing files.

E.g if you want to read in "copy.csv", moving the file's location to "Users\Public\copy.csv" should allow you to read it without explicitly setting permissions for postgres/pgadmin

like image 57
ZeThey Avatar answered Dec 11 '25 08:12

ZeThey