Install MongoDB on Mac

MongoDb on MAC

In this quick tutorial, I am going to be showing you how to install MongoDB with the 4 STEPS on your MAC.

    • 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.

STEP #2 Install MongoDB

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

Next, create a folder by typing the following command:

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.

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

Now, open up two Terminal Windows, one is to run MongoDB Server and other one is Mongo Shell where you can write  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.

Sometimes, writing queries on the Mongo Shell would 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:

ServerConfiguration

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 Shell

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

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

Thank You for reading…

Arif Khoja
Arif Khoja is a Developer. He is a Javascript Enthusiatic who loves logical programming and has first hand experience in building a cutting edge internet product using Angular. He is also an open source freak and keen about learning and sharing. He writes Javascript both frontend and backend. He loves learning and sharing tech all the time. He also has a hands on experience in SEO and writes articles about latest emerging technologies.
Arif Khoja on FacebookArif Khoja on GoogleArif Khoja on InstagramArif Khoja on LinkedinArif Khoja on Twitter

Leave a Reply

%d bloggers like this: