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