I am trying to copy a file, but getting error message

﹥>﹥吖頭↗ 提交于 2020-01-25 09:36:08

问题


I am new to postgres, probably missing something silly like (the correct name of my directory). Can someone guide me?

I am following book instructions, Practical SQL by Anthony DeBarros

Code:

copy us_counties_2010 from 'C:\Users\obella\OneDrive\Desktop\us_counties_2010.csv' with (FORMAT CSV, HEADER);

Error:

ERROR: could not open file "C:\Users\obella\OneDrive\Desktop\us_counties_2010.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

copy us_counties_2010 from 'C:\Users\obella\OneDrive\Desktop\us_counties_2010.csv' with (FORMAT CSV, HEADER);

Expected:

Query returned successfully: 3143 rows affected

Actual:

ERROR: could not open file "C:\Users\obella\OneDrive\Desktop\us_counties_2010.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


回答1:


As the message tells you, Postres is not allowed to read the file.

If you want to fix that open the Task Manager, and click on "Show processes from all users". Look for the rows with the image name postgres.exe (likely more than one). Remember the value in the column "User Name" (it's probably NETWORK SERVICE). Open the properties of your file, add that user in the "Security" tab and grant read access to them.

Or use psql's \copy as the message suggests.



来源:https://stackoverflow.com/questions/54031813/i-am-trying-to-copy-a-file-but-getting-error-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!