Install MongoDB on Mac OS X
First, install Homebrew, which is the missing package management tool for OS X:
> ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Next, update the formulae:
> brew update
Then, install MongoDB:
> brew install mongodb
To have launchd
start MongoDB at login, run:
> ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
To load MongoDB immediately, execute:
> launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Alternatively, if you don’t want or need launchctl
, you can simply run:
> mongod --config /usr/local/etc/mongod.conf
Also, create the data directory:
> sudo mkdir -p /data/db
Don’t forget to change the permissions:
> sudo chown "$(whoami)" /data/db
Finally, start your database:
> mongod