How to Install MongoDB on MacOs

Hello Night Crawler ...

MongoDB is a nosql database that works as stored documents. These documents are JSON objects that carry less relational data structure properties than popular SQL databases. MongoDB is meant to reduce the response times of DB requests, and when used correctly; can improve the performance of an application.

We'll be using brew to install MongoDB. Let's start by updating your brew installation.

brew update

Now we can install Mongo using brew.

brew install mongodb a Congrats ... you've just downloaded mongo. Look at you go ... to town ... and getting bananas and stuff.

Now we need to create the DB directory. Remember, a mongodb database is a collection of json objects. This will be the directory that we'll be throwing them in. This will be our default location.

Let's create the direcory:

mkdir -p /data/db

If you're not sure about the permissions of the directory, you can modify them:

sudo chown -R /data/db OR you could run sudo chown -R id -un /data/db

After you've entered your password, you should be able to run your mongodb daemon like so:


in a new terminal tab. This should start the mongo server.

Now we can run the mongo shell:

mongo ... make sure to run this in a new tab.

To exit the mongo shell run : quit()

To stop the mongo daemon run : ctrl + c

"MongoDB is a nosql database that works as stored documents"

The Village Geek

Aaannd there you have it soldier ... Mongo in all it's glory.

Enjoy, play around, create some collections, and get a bit more comfortable with the mongo shell.

Cape Town, South Africa

Buy me a coffee ? :) Buy me a coffee :)

Reply to this discussion


Coming Soon ...