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

时间:2016-01-14 19:25:23

标签: macos postgresql osx-elcapitan

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

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

尝试cd /usr/local/var/postgres时,我得到了:

cd: permission denied: /usr/local/var/postgres

似乎我没有适当的许可来这样做。我认为这与El Capitan的System Integrity Protection有关,但我可能错了。

我该如何解决这个问题?

3 个答案:

答案 0 :(得分:22)

sudo chown -R `whoami` /usr/local

答案 1 :(得分:9)

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

所以我这样做了:

sudo chown -R `whoami` /usr/local && brew postinstall postgresql

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

答案 2 :(得分:2)

我发现chown所有/usr/local目录的效率和安全性都不高,所以我做的很简单 mkdir /usr/local/var/postgres

一切顺利。