【问题标题】:initdb /usr/local/var/postgres on El CapitanEl Capitan 上的 initdb /usr/local/var/postgres
【发布时间】:2016-01-14 19:25:23
【问题描述】:

在 El Capitan 上通过 homebrew 安装 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 有关,但我可能是错的。

我该如何解决这个问题?

【问题讨论】:

    标签: macos postgresql osx-elcapitan


    【解决方案1】:

    sudo chown -R `whoami` /usr/local

    【讨论】:

    • 感谢您分享完整的chown 语法
    【解决方案2】:

    我必须将我看到的两条建议与与此问题/错误相关的 Stack Overflow 问题结合起来。我发现自己处于先有鸡还是先有蛋的境地,我会重新安装 postgres 并一次更改一个权限,但两个命令相互冲突。

    所以我这样做了:

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

    ...效果很好。

    【讨论】:

    • 该命令应该使用“postinstall”而不是“post install”
    【解决方案3】:

    我发现chown all /usr/local 目录不是很有效和安全,所以我只是简单地做了 mkdir /usr/local/var/postgres

    一切都很顺利。

    【讨论】:

    • 我用 Homebrew 安装了一个陈旧的 PostgeSQL,卸载它,删除了我用find / -name postgres 找到的所有 postgresql 文件,然后mkdir /usr/local/var/postgres 让我安装愉快。
    猜你喜欢
    • 2016-02-19
    • 1970-01-01
    • 1970-01-01
    • 2016-07-21
    • 2015-11-01
    • 2015-12-28
    • 2015-12-20
    • 1970-01-01
    • 2016-03-12
    相关资源
    最近更新 更多