简体   繁体   English

在自制中链接PostgreSQL

[英]Linking postgresql in homebrew

I already installed postgresql, but it says I did not link to it. 我已经安装了postgresql,但是它说我没有链接到它。 I am running this in the command line and getting the following error: 我在命令行中运行此命令并收到以下错误:

myname@MacBook-Pro-8 ~> brew install postgresql
Warning: postgresql 10.4 is already installed, it's just not linked
You can use `brew link postgresql` to link this version.
myname@MacBook-Pro-8 ~> brew link postgresql
Linking /usr/local/Cellar/postgresql/10.4...
Error: Could not symlink share/man/man7/ABORT.7
/usr/local/share/man/man7 is not writable.
myname@MacBook-Pro-8 ~> sudo brew link postgresql
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system.

I also tried: 我也尝试过:

brew prune; brew link postgresql

which gave me the same error: 这给了我同样的错误:

Error: Could not symlink share/man/man7/ABORT.7
/usr/local/share/man/man7 is not writable.

Why is that folder not writable and what can I do to change that? 为什么该文件夹不可写?我该怎么做才能更改它?

It was really painful solving this problem, so I figured I would leave it here for others to see. 解决这个问题真的很痛苦,所以我想把它留给别人看看。

Issue: Homebrew install of Postgresql will not execute successfully. 问题: Postgresql的Homebrew安装将无法成功执行。 $ brew link postgresql results in failure due to directory not writable. $ brew link postgresql由于目录不可写而导致失败。 New version of Homebrew will not allow sudo commands and System Integrity Protection prevents changing permissions. 新版本的Homebrew将不允许sudo命令,并且系统完整性保护可防止更改权限。

Details: I tried to use homebrew to install postgres and kept running into issues with syslink. 详细信息:我尝试使用自制软件安装postgres,并不断遇到syslink问题。 When I ran $ brew link postgresql as homebrew suggested, I kept running into an error that it couldn't be completed because certain folders were not writable. 当我按照自制软件的建议运行$ brew link postgresql ,我一直遇到一个错误,因为某些文件夹不可写,所以无法完成。 I thought this would be easily remedied by running sudo but unfortunately the most current version of homebrew no longer allows the use of sudo commands due to security risks. 我认为通过运行sudo可以很容易地解决此问题,但是不幸的是,由于安全风险,最新版本的homebrew不再允许使用sudo命令。 My next thought was to my root user and use the macOS GUI interface to change the permissions on this folder because I am not sure how to do this on the terminal. 我的下一个想法是让我的root用户使用macOS GUI界面来更改此文件夹的权限,因为我不确定如何在终端上执行此操作。 Regardless of being logged in as 'root,' the OS would not let me change the permissions of the folder. 不管以“ root”身份登录,操作系统都不允许我更改文件夹的权限。 I also attempted to use sudo and change the permissions in terminal and it did not work either. 我也尝试使用sudo并在终端中更改权限,但是它也不起作用。 After several days of banging my head against the wall try all kinds of things to find a solution, I discovered that since El Capitan, macOS introduced System Integrity Protection aka 'SIP' or 'rootless.' 经过几天的脑筋急转弯尝试各种解决方案,我发现自El Capitan以来,macOS引入了系统完整性保护(又称为“ SIP”或“无根”)。 As it turned out, once I disabled SIP, logged back into 'root' and changed my regular accounts permissions to Read/Write on the problem directories, I was able to go back to my regular account and successfully execute $ brew install postgresql. 事实证明,一旦我禁用了SIP,重新登录到“ root”并在问题目录上将我的常规帐户权限更改为“读/写”,就可以返回我的常规帐户并成功执行$ brew install postgresql。

(Assuming you currently have postgresql installed through homebrew but unable to link due a scenario like the one mentioned above, here is what I suggest to resolve your issue...) (假设您当前通过自制软件安装了postgresql,但由于上述情况而无法链接,这是我建议您解决的问题...)

  1. Run $ brew link postgresql 运行$ brew link postgresql
  2. Write down the directory path that the error says it is not able to write to. 写下错误指出无法写入的目录路径。 (eg usr/local/share/man/man7) NOTE: you'll want to actually write this down on paper or take a picture of the screen on your phone because you will not be able to use copy and paste) (例如usr / local / share / man / man7)注意:您将要在纸上写下或在手机屏幕上拍照,因为您将无法使用复制和粘贴功能)
  3. Enable your 'root' user account if you have not already done so. 启用您的“ root”用户帐户(如果尚未启用)。 ( instructions here ) NOTE: make sure to make a really good password for this account and write it down somewhere safe. 此处的说明 )注意:确保为此帐户输入一个非常好的密码,并将其写下来安全的地方。 This is a powerful account and there's no way to recover the password. 这是一个功能强大的帐户,无法恢复密码。
  4. Disable System Integrity Protection. 禁用系统完整性保护。 ( instructions here ) 这里的说明
  5. Log into 'root' user account 登录到“ root”用户帐户
  6. In Finder menu bar select GO > GO TO FOLDER... (CMND + SHFT + G) and type in the path from Step 2. 在Finder菜单栏中,选择GO>转到文件夹...(CMND + SHFT + G),然后输入步骤2中的路径。
  7. Right-Click/ Cntrl-Click the folder and select Get Info 右键单击/ Cntrl单击该文件夹,然后选择“获取信息”
  8. Click the plus sign at the bottom of Sharing & Permissions 单击共享和权限底部的加号。
  9. Add your regular account to the list and change the permission to Read & Write 将您的普通帐户添加到列表中,并将权限更改为“读写”
  10. Go back to your regular account, run $ brew uninstall postgresql , then $ brew update and $ brew doctor . 回到您的常规帐户,运行$ brew uninstall postgresql ,然后运行$ brew update$ brew doctor If those are all set run $ brew install postgresql . 如果所有这些都设置,运行$ brew install postgresql
  11. You should be able to install without any problems now. 您现在应该可以安装而没有任何问题。 However, if you run into a linking and permissions problem again, run $ brew link postgresql to figure out the problematic directory and repeat Steps 5 - 10 with whatever other directories are giving you trouble. 但是,如果再次遇到链接和权限问题,请运行$ brew link postgresql以找出有问题的目录,并对其他给您带来麻烦的目录重复执行步骤5-10。
  12. If everything is up and running properly. 如果一切正常并且运行正常。 It is probably best to at least enable SIP again (instruction in the article linked in Step 4). 最好至少再次启用SIP(步骤4中链接的文章中的说明)。

(To check that everything is working. I recommend running $ brew services start postgresql then $ createdb 'test' . In my case, it was when I originally tried to run createdb and got "command not found" that I realized something was wrong.) (要检查一切是否正常。我建议先运行$ brew services然后启动postgresql,然后运行$ brew services $ createdb 'test' 。就我而言,这是当我最初尝试运行createdb并得到“找不到命令”时,我意识到出了点问题。 )

Running this solves it. 运行此即可解决。 This gets around SIP. 这绕过SIP。

sudo chown -R $(whoami) $(brew --prefix)/*
brew link postgresql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM