Postgres无法访问服务器配置文件:权限被拒绝。

4

这让我感到困惑(尝试在MacOS Lion上设置postgres):

delirium:$ sudo ls -al /usr/local/pgsql/data/
total 64
drwx------  15 postgres  postgres    510 25 May 10:36 .
drwxr-xr-x@ 13 103       103         442 25 May 10:35 ..
-rw-------   1 postgres  postgres      4 25 May 10:36 PG_VERSION
drwx------   5 postgres  postgres    170 25 May 10:36 base
drwx------  41 postgres  postgres   1394 25 May 10:36 global
drwx------   3 postgres  postgres    102 25 May 10:36 pg_clog
-rw-------   1 postgres  postgres   3652 25 May 10:36 pg_hba.conf
-rw-------   1 postgres  postgres   1631 25 May 10:36 pg_ident.conf
drwx------   4 postgres  postgres    136 25 May 10:36 pg_multixact
drwx------   2 postgres  postgres     68 25 May 10:36 pg_stat_tmp
drwx------   3 postgres  postgres    102 25 May 10:36 pg_subtrans
drwx------   2 postgres  postgres     68 25 May 10:36 pg_tblspc
drwx------   2 postgres  postgres     68 25 May 10:36 pg_twophase
drwx------   4 postgres  postgres    136 25 May 10:36 pg_xlog
-rwxr-xr-x   1 postgres  postgres  16879 25 May 10:36 postgresql.conf
delirium:$ /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
postgres cannot access the server configuration file "/usr/local/pgsql/data/postgresql.conf": Permission denied

输出结果不是显示Postgres是postgresql.conf所有者吗?那么为什么它不能访问该文件?

我该怎么办?


这是一个SuperUser或ServerFault的问题,而不是StackOverflow的问题... - aleroot
抱歉,如果您愿意,我可以将其迁移到ServerFault。 - flossfan
您是否使用 user=postgres 用户执行该命令? - wildplasser
文件的模式为0755(应该是0644),目录为0700,这意味着:只有postgres可以访问该目录。通过 sudo -u postgres /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data 启动该进程。 - wildplasser
@wildplasser 为什么0755和0644会有所不同呢?在任何情况下,postgres都是尝试运行它的用户,并且每个目录和文件的所有者和组都是相关的。 - Adam Winter
2个回答

3
诊断权限被拒绝错误的最快方法是以该用户身份登录(使用susudo),然后尝试cat该文件。
如果这是权限被拒绝而不是文件未找到,我猜测postgres用户在其中一个父目录上没有执行权限,它可能是这三个目录中的任何一个:/usr/local/pgsql/

2
如果用户(postgres)可以查看该文件,那么怎么办? - Adam Winter

0
sudo -u postgres /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data

假设Postgres是使用默认用户postgres设置的


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接