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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10752075/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-20 23:57:00  来源:igfitidea点击:

postgres cannot access the server configuration file: Permission denied

postgresqlosx-lionpostgresql-9.1

提问by flossfan

This is baffling me (trying to set up postgres on MacOS Lion):

这让我很困惑(试图在 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

Doesn't the output show that postgres is the ownerof postgresql.conf? So why can't it access the file?

不输出显示,Postgres的是业主postgresql.conf?那么为什么它不能访问该文件呢?

What can I do?

我能做什么?

回答by Philip Couling

The quickest way to diagnose a permission denied error is to login (suor sudo) as that user and try to catthe file.

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

If this is permission denied and not file not found, I'm guessing the postgres user has not got execute permissions on one of the parent directories, it could be any of the 3: /usr/local/pgsql/

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

回答by PartialOrder

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

...assuming postgres was set up with default user postgres

...假设 postgres 是用默认用户设置的 postgres