尝试启动通过Homebrew安装的Postgres时出错:不允许操作


24

我最近通过Homebrew在Mac上安装了Postgres。(我可能已经安装了它但没有运行)

brew install postgres
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents

现在,我尝试以launchctl:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

...但是我收到一个错误:

/usr/local/Cellar/postgresql/9.4.0/homebrew.mxcl.postgresql.plist: Operation not permitted

这个错误是什么意思?我究竟做错了什么?我该如何解决该问题?


显然brew / OSX 有时需要重新启动才能正常工作。在我们全部进入问题解决模式之前:您是否尝试过将其关闭然后再打开?
— 2015年

重启不会改变任何东西。
— 尼尔

同意,重新启动无法解决问题。
— 安德鲁(Andrew)

Answers:


84

可能是您在launchctlTmux或Screen内部使用。

Tmux和Screen a终端多路复用器产生多个“屏幕”,您可以在一个终端中轻松切换。

由于某些我不知道的原因,launchctl在Tmux内部运行永远无法正常工作,并发出错误消息Operation not permitted。在普通外壳中运行它,可能会正常工作。


谢谢!您说对了,我在用tmux!但是,我现在似乎遇到了另一个问题。launchctl在之外使用tmux,我看到“操作已在进行中”,但无法连接到Postgres。
— 安德鲁

我设法通过以下几种组合来解决我的问题:unload启动代理plist,删除Postgres的旧安装,移动旧的数据目录并重新安装最新版本。
— 安德鲁(Andrew)

最终,我偶然发现了这个问题,并回答了为什么我一直在奋斗一个多月。终于我知道了感谢的原因...
— kenju254

2
一种解决方案是使用此处所述的重新连接到用户会话:apple.stackexchange.com/questions/41412/…在您的.tmux.conf中
— bibstha 2015年

2

以下是您可能需要采取的步骤:

删除以前安装的Postgres:

brew remove postgres
rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

安装新版本:

brew install postgres
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents

您之前安装的数据将需要升级,以与Postgres 9.4+兼容:http : //www.postgresql.org/docs/9.4/static/upgrading.html

似乎您需要两次安装Postgres才能升级数据库,而我对此并不在意,所以我只是用新版本重新创建了数据库:

mv /usr/local/var/postgres /usr/local/var/old-postgres
initdb -D /usr/local/var/postgres

现在启动Postgres(tmux如果正在使用的话):

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

检查日志中是否存在任何问题:

tail /usr/local/var/postgres/server.log

0

运行是否可以brew doctor解决问题或以其他方式解决问题?

(我目前无法发表评论,但这可能有助于解决问题)

编辑-我将运行:

brew doctor
brew update
brew doctor
brew cleanup

即使清除了中的任何警告也无济于事brew doctor。
— 尼尔
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.