Josh Pittman
Josh Pittman

Reputation: 7324

Tried installing MongoDB with brew and it says "Error: Permission denied - (mongod.conf, /usr/local/etc/mongod.conf)"

Using Mac OSX 10.10.4 on 13' Macbook Air

Typed in 'brew update' like the Mongo docs said and it updated Then typed 'brew install mongodb' and it took ages to say

Error: Permission denied - (mongod.conf, /usr/local/etc/mongod.conf)

This is what the console said leading up to that point, in case this helps:

Joshuas-Air:~ Josh$ brew install mongodb
==> Downloading https://homebrew.bintray.com/bottles/mongodb-3.0.4.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mongodb-3.0.4.yosemite.bottle.tar.gz
Error: Permission denied - /usr/local/etc/mongod.conf
Warning: Bottle installation failed: building from source.
==> Installing mongodb dependency: scons
==> Downloading https://homebrew.bintray.com/bottles/scons-2.3.5.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring scons-2.3.5.yosemite.bottle.tar.gz
🍺  /usr/local/Cellar/scons/2.3.5: 208 files, 2.4M
==> Downloading https://fastdl.mongodb.org/src/mongodb-src-r3.0.4.tar.gz
######################################################################## 100.0%
==> Cloning https://github.com/mongodb/mongo-tools.git
Updating /Library/Caches/Homebrew/mongodb--github.com-mongodb-mongo-tools--git
==> Checking out tag r3.0.4
==> ./build.sh
==> /usr/local/opt/scons/bin/scons install --prefix=/usr/local/Cellar/mongodb/3.0.4 -j4 --osx-version-min=10.10 --cc=/usr/bin/clang --cxx=/usr/bin/clang++ --use-new-tools
Error: Permission denied - (mongod.conf, /usr/local/etc/mongod.conf)
Joshuas-Air:~ Josh$ 

Any help at all would be appreciated.

Upvotes: 3

Views: 6118

Answers (3)

Kris Wheeler
Kris Wheeler

Reputation: 279

I had mostly the same error. I could not solve the problem by chown'ing the /usr/local directories as the prompts suggest possibly due to my upgrade to High Sierra. I was able to succeed installing mongodb by reinstalling homebrew using the following command:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This allowed my subsequent brew install mongodb to work.

Upvotes: 3

MiVvlt
MiVvlt

Reputation: 111

I had the same problem, changing the directory permissions didn't work for me so eventually I've found this solution:

  1. Download the most recent version (.tgz).
  2. Open the terminal and head to the ~/Downloads folder or wherever you saved the file.
  3. Untar: tar xvf filename.tgz.
  4. Enter the directory and go to the bin directory.
  5. At the terminal use the sudo bash (become root) command.
  6. Now enter the command cp * /usr/local/bin.
  7. Create /data/db directories (optional, this is the default location MongoDB uses).
  8. At the terminal use the command exit to exit root user.
  9. which mongo should now respond with /usr/local/bin and you are all set to go.

Upvotes: 2

Kirell
Kirell

Reputation: 9808

My guess is that the permissions on the folder /usr/local/ are not set 755 or 777. You can change the permissions or simply try to run the command as root:

sudo brew install mongodb

Upvotes: 0

Related Questions