Install MongoDB on Mac OS X

October 09, 2015

2015 10 10

First, install Homebrew, which is the missing package management tool for OS X:

> ruby -e "$(curl -fsSL"

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

Profile picture

Victor Leung, who blog about business, technology and personal development. Happy to connect on LinkedIn