【问题标题】:postgres cannot access the server configuration file: Permission deniedpostgres 无法访问服务器配置文件:权限被拒绝
【发布时间】:2012-05-25 09:42:46
【问题描述】:

这让我很困惑(试图在 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 问题...
  • 对不起,如果你愿意,我可以将它迁移到 ServerFault...
  • 你是否以 user=postgres 的身份执行命令?
  • 文件是模式0755(应该是0644),目录是0700,也就是说:只有postgres可以访问该目录。通过sudo -u postgres /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data启动野兽
  • @wildplasser 为什么 0755 与 0644 很重要?在任何一种情况下,postgres 都是试图运行它的用户,以及每个相关目录和文件的所有者和组。

标签: postgresql osx-lion postgresql-9.1


【解决方案1】:

诊断权限被拒绝错误的最快方法是以该用户身份登录(susudo)并尝试cat 文件。

如果这是权限被拒绝且未找到文件,我猜 postgres 用户没有对其中一个父目录的执行权限,它可能是 3 个中的任何一个:/usr/local/pgsql/

【讨论】:

  • 如果用户(postgres)可以 cat 文件?然后呢?
【解决方案2】:
sudo -u postgres /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data

...假设 postgres 设置为默认用户 postgres

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-06
    • 1970-01-01
    • 2015-11-09
    • 2016-01-31
    • 2016-03-05
    • 2013-07-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多