Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm using PGAdmin 1.14.3.

When I try to execute an import command:

COPY grad(country_code, postal_code, place_name, admin_name1, admin_code1, admin_name2, admin_code2, admin_name3, admin_code3, latitude, longitude, accuracy)
FROM 'C:\Users\denis\Desktop\BP2Project\USA\US.txt';

I get a

ERROR: could not open file "C:UsersdenisDesktopBP2ProjectUSAUS.txt" for reading: Permission denied SQL state: 42501

I did look up other similar questions and none of them solved my issue.

I logged in as user "postgres" who is the superuser. I don't see why I'm missing permissions. I'm on Windows 7.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
598 views
Welcome To Ask or Share your Answers For Others

1 Answer

The permissions article mentioned in the answer by Houari and Flimzy is a good reference material, but a direct answer (the quick fix I used) is:

  • Right click the folder containing the data file(s) that permission was denied to and then click Properties.
  • In the Folder's Properties window, select the Security tab.
  • Click the Edit button.
  • In the "Permissions for the folder" window that opened, click the Add... button.
  • Type Everyone into the "Enter the object names to select" text area box.
  • Click OK and the window will close.
  • Verify that the default Read & Execute permissions were set to Allow via the check checkbox in the previous window.
  • Click OK and the window will close.
  • Click the Apply button in the Folder Properties window.

Now you can run the SQL COPY statement that needs to access those files.

  • Once done, return to the Folder's Properties window.
  • Click the Edit button.
  • Select the Everyone entry in the "Group or user names:" field.
  • Click the Remove button.
  • Click OK on the remaining open windows.

The permissions have now been returned to what they were.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...