Setting MongoDB Developing Environment

Installing MongoDB - Mac OS X

Among different ways of installing MongoDB on Mac OS X, I recommend the simplest way of installing and configuring by using Homebrew with CURL command from MongoDB binaries. If Homebrew has not already installed on your machine, following the steps in Installing Homebrew section below in this post.
1. First, Type brew update to update Homebrew to latest version.
2. There are several different options in installing MongoDB. If you want to install only MongoDB Binaries, type brew install mongodb. If you want MongoDB built from Source with TLS/SSL Support, type brew install mongodb --with-openssl. If you prefer the latest development release, type brew install mongodb --devel.
3. In this post, I will go with ordinary MongoDB binaries. It will take a few seconds for downloading and compiling MongoDB components in your system files.

Installing MongoDB Binaries Complete

Running MongoDB

  1. Before you can start MongoDB for the first time, you need to define the default directory where all the data being saved that mongod process uses.
  2. Type sudo mkdir -p /data/db in Terminal to create default /data/db folder in your disk root directory.
  3. Type your admin-level password when prompt.
  4. Before running mongod process for the first time, make sure that you have both read and write permissions for the /data/db directory. The permission has been already set normally. If not, type 'sudo chmod 777 /data/db' to change permissions security settings for /data/db.
  5. Then, you can type mongod in Terminal to start Mongod process which is a background service instance for MongoDB. You will see multiple lines in Terminal window like the following ss.Mongod Instance Running
  6. To stop mongod process, press Ctrl + c in the Terminal window where the mongod instance is running.

Installing Homebrew

  1. Visit, the official page of Homebrew.
  2. You can directly paste this command in Terminal or copy from its page. /usr/bin/ruby -e "$(curl -fsSL"
  3. You will see a dialog box to install Xcode or Command line developer tools from the App Store after entering above xcrun command. You can simply press Install in that dialog box or Get Xcode from App Store.
  4. After installing Command line developer tools, press Return to continue installing Homebrew.
  5. Type your admin-level password if prompt.
  6. You will see Installation successful! after a moment. Then, Homebrew is successfully installed on your machine.
    Successful Homebrew Installation

Nay Win Myint

Founder and CEO of Pancasikha Music Streaming Provider, JavaScript full-stack and Android developer and Graphic designer.

Rangoon, Myanmar