JavaScript Tutorials

4 STEPS to Install MongoDB on Mac

Last modified on April 18th, 2020
Raja Tamil

In this quick tutorial, I am going to be showing you how to install MongoDB in 4 easy STEPS.

  • Install Brew
  • Install MongoDB
  • Run Mongo Server
  • Make A query To MongoDo

STEP #1 Install Brew

Open up your terminal by going to Applications -> Utilities -> Terminal and Copy and Paste the following command into the Terminal. Hit enter to begin installing brew.

/usr/bin/ruby -e "$(curl -fsSL"

STEP #2 Install MongoDB

Once Brew is installed, it is time to install MongoDB by issuing the following command on the Terminal:

brew install mongodb

Next, create a folder by typing the following command:

sudo mkdir -p /data/db

You will be prompted to enter your computer password. The below command will take you to the folder path that contains all of the mongo server files.

sudo chown yourhomedirectoryname /data/db

That’s it! At this point, you have successfully installed MongoDB on your Mac!

Now, open up two Terminal Windows, one is to run the MongoDB server and the other one is Mongo Shell where you can write Mongo Queries.

STEP #3 Run Mongo Server

Type the command below to start the server.


Now, the server is running. If you want to stop the server, you can use the Control + C keyboard shortcut or close the Terminal window.

STEP #4 Make A Query To MongoDB

Once the server is up and running, open up a new tab in the Terminal window and type the command below that will give you the mongo shell in which you can write mongo queries.


If you want to see all the databases, use the following command.

show dbs

Sometimes, writing queries on the Mongo Shell will be really hard because there is no syntax highlight and it becomes tedious when you execute big queries.

Luckily, I recently found a mac application called MongoBooster (FREE) that will replace the mongo shell Terminal window. Remember, you must keep the server running.

Once you install MongoBooster, you need to connect to the server by going to File→ Connect→ Create and add your server information.

The server has to be “localhost” and the port is “27017” which is a default Mongo Server port. See the screenshot below:

Mongobooster - Mongoshell

Once you have successfully connected to the server via MongoBooster, you can start writing Mongo queries in the Mongo Shell which is nice like below.

mongo booster - mongo shell

All you have to do is write some mongo queries on the top window and click the RUN button and you can see the result on the bottom window.

I really enjoy working with MongoBooster as it gives me code completion and syntax highlight.

Thank you for reading…