在Mac上通过Homebrew安装PostgreSQL出现错误

3
在Mac(OSX 10.11.6)上通过Homebrew安装PostgreSQL时,我遇到了以下错误:
Error: The `brew link` step did not complete successfully The formula
  built, but is not symlinked into /usr/local

并且

initdb: file "/usr/local/share/postgresql/postgres.bki" does not exist
  This might mean you have a corrupted installation or identified the 
  wrong directory with the invocation option -L.
/postgresql文件夹不存在。
不确定是否相关,但我已经通过Homebrew安装了OpenSSL 1.0.2o_2和Readline 7.0.5。
有人知道为什么会出现这个错误以及如何解决吗?

在使用Homebrew安装Postgres时遇到了一些问题。发现https://postgresapp.com/可以用于在OSX上管理不同版本的PostgreSQL。 - andro83
谢谢你的建议,我一直在苦苦寻找解决方案。我可能会尝试那个方法! - Robert Samarji
你看过 brew doctor 的输出了吗?也许它能给你一些线索。另外,你能展示一下你是如何通过 Homebrew 安装 PostgreSQL 的吗? - anothernode
1
目录/usr/local/share/postgresql应该包含Homebrew安装成功后所有符号链接到相关文件的内容。所以,我猜问题是为什么在您的情况下这个目录和符号链接没有被创建。我刚刚在我的机器上执行了brew reinstall postgresql,它可以正常工作。您可能手动更改了/usr/local/share的权限吗? - anothernode
谢谢anothernode。你说得对,这是一个权限问题。递归地使用sudo chown命令更改/user/local/share文件夹的所有权解决了问题。 - Robert Samarji
在 Mac M2 上使用 brew 安装 Postgresql:https://dev59.com/questions/fVEG5IYBdhLWcg3wPXpF#75885761 - ugola
2个回答

12
在我的情况下,我已经安装了libpq,这阻止了postgresql的链接。先解除libpq的链接然后连接postgresql可以为我解决这个问题。
brew unlink libpq
brew link postgresql
brew postinstall postgresql

2
这对我来说也是同样的情况。 - GvSharma
这个回复值得一枚奖牌 - mzrnsh
这个回复真的值得一枚奖牌 - undefined

0

成功解决了问题。这是一个权限问题。原始答案可以在这里找到:Homebrew: Could not symlink, /usr/local/bin is not writable

简而言之,请执行以下命令:

sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share
sudo chown -R `whoami`:admin /usr/local/opt

这对我没用。仍然出现相同的错误。 - demisx

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接