Brew Install MongoDB. Permission Denied

  

➜ models git:(master) brew install mongodb
==> Downloading https://homebrew.bintray.com/bottles/mongodb-3.0.7.el_capitan.bo
Already downloaded: /Library/Caches/Homebrew/mongodb-3.0.7.el_capitan.bottle.tar.gz
==> Pouring mongodb-3.0.7.el_capitan.bottle.tar.gz
Error: Permission denied - /usr/local/var

因为是权限的问题,之后brew又自己选择了进行git clone源码,然后编译,其实是没有什么用的,因为/usr/local的权限是没有的。

解决办法:

brew update

Error: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.
sudo chown -R $(whoami):admin /usr/local

 所以只要 sudo chown -R $(whoami):admin /usr/local

就可以解决了

原文地址:https://www.cnblogs.com/-Doraemon/p/4913199.html