How to install MongoDB on Mac OS X

How to install MongoDB on Mac OS XIn this post we will see How to install MongoDB on Mac OS X. MongoDB is one of the most used, open-source document database, and NoSQL database. MongoDB is developed by 10gen.

STEP 1 – Downloading MongoDB .tgz file

Visit MongoDB official website and download the .tgz file from the community section of the website.
Now extract the downloded .tgz and mv the mongo directory to /usr/local/mongodb directory using following command in terminal.

STEP 2 – Create MongoDB Data directory (/data/db)

MongoDB stores the data into the /data/db directory by default, so we need to create this directory and also assign proper permission using chown command.
Open the terminal run the following command

STEP 3 – Set mongodb/bin PATH to ~/.bash_profile

Now we need to set the envirent variable for MongoDb, So the mongo and mongod command can be recognized from the terminal.
For that we need to add the mongodb/bin path to the ~/.bash_profile file.

Now .bash_profile file will open in a text editor. In this file add the following exports

Now restart your terminal and verify the mongodb version by following commands

STEP 4 – Start MongoDB

In order to work with mongodb we need to first run the mongod command which starts the mongo daemon .
So open two different terminals.
Now in

terminal 1

run the following command

Now in

terminal 2

run the following command

Partner Sites

Stuff I use to make videos

Windows notebook –

Apple MacBook Pro –

Desktop -

Microphone –

notebook mouse –

Screen Recording Software – Camtasia

  • Jaime H


    I follow the instructions; however when running the mongod i got this message.

    -iMac:~ Ja$ mongod

    dyld: Symbol not found: _fchmodat

    Referenced from: /usr/local/mongodb/bin/mongod

    Expected in: /usr/lib/libSystem.B.dylib

    in /usr/local/mongodb/bin/mongod

    Trace/BPT trap: 5