gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 19:31:31 28 4
gpt4 key购买 nike

我正在使用 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com