我正在尝试复制文件,但收到错误消息 [英] I am trying to copy a file, but getting error message

查看:1183
本文介绍了我正在尝试复制文件,但收到错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Postgres的新手,可能缺少一些愚蠢的东西(目录的正确名称)。有人可以指导我吗?

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

我正在按照书中的说明进行操作,Anthony DeBarros编写的实用SQL

I am following book instructions, Practical SQL by Anthony DeBarros

代码:



复制us_counties_2010'C:\Users\obella\OneDrive\Desktop\us_counties_2010.csv'(格式
CSV,标题);

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

错误:


错误:无法打开文件
C:\Users\obella\OneDrive\Desktop\us_counties_2010.csv读取:
权限被拒绝提示:COPY FROM指示PostgreSQL服务器
进程读取文件。您可能需要客户端工具,例如
psql的\copy。 SQL状态:42501

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


复制us_counties_2010'C:\Users\obella\OneDrive\Desktop\us_counties_2010.csv'与(FORMAT
CSV,HEADER);

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

期望:


查询成功返回:3143行受影响

Query returned successfully: 3143 rows affected

实际:


错误:无法打开文件
C:\Users\obella\OneDrive\Desktop\us_counties_2010.csv,用于读取:
权限被拒绝提示:COPY FROM指示PostgreSQL服务器
进程读取文件。您可能需要客户端工具,例如
psql的\copy。 SQL状态:42501

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


推荐答案

如消息所示,Postres不允许读取文件。

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

如果要修复此问题,请打开任务管理器,然后单击显示所有用户的进程。查找图像名称为 postgres.exe 的行(可能不止一个)。记住用户名列中的值(可能是 NETWORK SERVICE )。打开文件的属性,在安全性选项卡中添加该用户,并授予对它们的读取访问权限。

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.

或使用 psql \copy 消息提示。

这篇关于我正在尝试复制文件,但收到错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆