El Capitan上的initdb/usr/local/var/postgres

Kyl*_*cot 9 postgresql macos osx-elcapitan

我试图initdb /usr/local/var/postgres在El Capitan上通过自制软件安装postgresql 9.5后运行,但我得到以下内容:

The files belonging to this database system will be owned by user "kyledecot".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /usr/local/var/postgres ... initdb: could not change permissions of directory "/usr/local/var/postgres": Operation not permitted
Run Code Online (Sandbox Code Playgroud)

cd /usr/local/var/postgres我试图得到:

cd: permission denied: /usr/local/var/postgres
Run Code Online (Sandbox Code Playgroud)

看来我没有这样做的适当许可.我认为这与El Capitan的系统完整性保护有关,但我可能错了.

我该如何解决这个问题?

Ant*_*ine 22

sudo chown -R `whoami` /usr/local

  • 感谢您分享完整的 `chown` 语法 (2认同)

Mik*_*ike 9

我必须结合我在Stack Overflow问题中看到的两个与此问题/错误相关的建议.我发现自己处于一个鸡和鸡蛋的情况下,我会重新安装postgres并一次更改一个权限,但这两个命令相互冲突.

所以我这样做了:

sudo chown -R `whoami` /usr/local && brew postinstall postgresql
Run Code Online (Sandbox Code Playgroud)

......它运作良好.