How to install MongoDB on Mac OS X

Steps to show how to install MongoDB on Mac OS X.

  1. MongoDB 3.0.7
  2. Mac OS X 10.11.1

The most straight forword way to install MongoDB is to use HomeBrew

1. Install MongoDB with Homebrew

First update Homebrew’s packages

brew update

Install the MongoDB Binaries

brew install mongodb

2. Create the data directory

By default, the mongod process uses the /data/db directory. Let’s create it:

sudo mkdir -p /data/db

3. Set permissions for the data directory for your current user

sudo chown `id -un` /data/db

4. Start MongoDB

mongod

5. Stop MongoDB

press Control+C in the terminal where the mongod instance is running.