How to Install MongoDB on Mac (Catalina)

A brief introduction to install and setup MongoDB.

In order to install MongoDB on your Mac, you should first install HomeBrew which is a package manager for Mac OS.

You can check if brew is already installed on your computer with this command in terminal:

brew --version

If you can’t see any version of brew you should install it. The following code snippets are terminal commands.

  1. Install Brew
/bin/bash -c "$(curl -fsSL"

2. Find the MongoDB tab

brew tap mongodb/brew

3. Install MongoDB

brew install mongodb-community

Now that you installed MongoDB you can create the db folder.

4. Create a new folder using sudo command:

sudo mkdir -p /System/Volumes/Data/data/db

Since you are using sudo command it may ask for a password. Enter the password you type when you open your Mac, and hit enter.

5. Give permission:

sudo chown -R `id -un` /System/Volumes/Data/data/db

6. Run MongoDB with brew

brew services run mongodb-community

7. Check whether MongoDB is running:

brew services list

You should see started status as green next to mongodb-community:

This means MongoDB is running.

When you are done with MongoDB you can ask HomeBrew to stop running mongo.

Use this command to stop MongoDB:

brew services stop mongodb-community

It’s time to use mongo shell with mongo command, and you can follow the topic in the next article.

Thanks for reading,

Take care,