postgresql - 无法使用 PostgreSQL 打开文件错误

标签 postgresql centos

我正在使用 PostgreSQL 和 Centos

在任务数据库中,我正在尝试执行此操作

COPY CUSTOMERS TO '/home/cjones/cfolder/customers.txt' (DELIMITER '|');

我得到了

错误:无法打开文件“/home/cjones/customers.txt”进行写入:权限被拒绝

我已经完成了 ls -al 和 chmod the customers.txt 到 777 并且仍然得到这个错误。有任何想法吗?

最佳答案

您了解所有要求吗? Per documentation:

1.

You must have select privilege on the table whose values are read by COPY TO



2.

COPY naming a file or command is only allowed to database superusers, since it allows reading or writing any file that the server has privileges to access.



另外,为了让服务器可以访问该文件,它当然必须位于同一台机器上。并且目录必须可供 postgres 服务器运行的用户访问,通常为 postgres (不仅是文件)。

另一种方法是使用 \copy meta-command of psql .

关于postgresql - 无法使用 PostgreSQL 打开文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27279182/

相关文章:

sql - 使用单个 SQL 关联子查询获取两列

javascript - 数组与 Postgres 中的数组重叠

centos - 如果已安装,如何在 Centos 7 中检查和运行 tesseract

python - pyodbc 值错误 : month must be in 1. 。 12

java - Tesseract OCR 无法在 Linux 上的 Java 中运行

sql - 编写 Postgres 获取或创建 SQL 查询

node.js - 使用事务时,查询中包含的子查询如何在 pg-promise 中工作?

java - 从 PostgreSQL 表中选择行范围

centos - 任何人都可以在一台笔记本电脑上配置多 VM 集群吗?

bash - SED 命令在 Vagrant Init 脚本中不起作用