How to install MongoDB on MAC with Yosemite OS

Here is quick guide to install MongoDB on your MAC running Yosemite OS. There are two easy ways to accomplish this task:

  1. Manually, through the official binaries
  2. Through Homebrew package manager for Mac OS

Installing MongoDB with Homebrew:

$ ruby -e "$(curl -fsSL"
$ brew update
$ brew install mongodb
-- Note that you can install these additional options
//Install with Open SSL support
$ brew install mongodb --with-openssl
//Install from the last available development release (not recommended for Production Environments)
$ brew install mongodb --devel

Now you have installed the MongoDB on your MAC system. Install MongoDB manually follow up these steps:

curl -O
tar -zxvf mongodb-osx-x86_64-3.0.3.tgz
mkdir -p mongodb
cp -R -n mongodb-osx-x86_64-3.0.3/ mongodb

Make sure that binaries are in your PATH, you can modify your PATH – you can add the following line to your shell’s rc file (~/.bashrc)

export PATH=mongodb-install-directory/bin:$PATH
-- where mongodb-install-directory is your path on your system

Before you start MongoDB for the first time, create the directory to which the mongod process will write data. By default, the mongod process uses the /data/db directory. If you create a directory other than this one, you must specify that directory in the dbpath option when starting the mongod process later in this procedure.
The following example command creates the default /data/db directory:

$ mkdir -p /data/db

Before you can run mongodb make sure as last thing that the user account running MongoDB has READ and WRITE permissions for the directory. To start MongoDB is very simple command:

$ mongod
MongoDB starting : pid=34022 port=27017 dbpath=/data/db/ 64-bit host=cloudman.local
waiting for connections on port 27017

If you are interested Udemy has excellent course as well as you can take FREE certificate course at MongoDB University or you can buy this good Guide book at Amazon:

Leave a Reply