Easy Way to Install MongoDB on MacOS

By Digamber Rawat Last updated on

Install MongoDB MacOS

In this tutorial I am going to talk about how you can install MongoDB on MacOS in an easy way. I have gone through many tutorials online, but I have been really upset with those tutorials. Most of the tutorials are outdated and old. So I decided to create this tutorial in which i can show you a better and easy way to setup MongoDB on MacOS.

Install MongoDB on MacOS using Homebrew

In order to install MongoDB on MacOs, I would suggest using Homebrew. Please open up the MacOs command line tool and paste the following command to setup MongoDB on MacOS.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Once you entered the given above command, your MacOS terminal will start some process. Those processes are nothing but related to creating some folder in your local machine where all the Homebrew related settings are kept. After finishing the installation process, check your Homebrew dependencies.

brew update

Hit the below commands to install MongoDB

brew install mongodb

After MongoDB successfully installed in your machine, then create a folder to store MongoDB data using given below command

sudo mkdir -p /mongo_data/db

Use the given below command to assign the proper permission to MongoDB data folder.

sudo chown -R `id -un` /mongo_data/db

We’ve successfully installed the MongoDB on MacOS also assigned the proper permission. Now it’s time to run mongo daemon service. This service makes the connection and performs the task in the background. Hit the following command to run MongoDB.


Now your apps are all set to communicate with MongoDB. Mongo is correctly working in the background with the help of mongo daemon. You might also check which MongoDB version you are working on, just hit the below command in the terminal.

mongo --version

mongo --version output

MongoDB shell version v4.0.6

git version: caa42a1f75a56c7643d0b68d3880444375ec42e3
allocator: system
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64

Above command will tell you which MongoDB version is running in your local machine. Using the latest version has always been a good practice. It protects you from compatibility chaos with client-side app

Digamber Rawat
Digamber Rawat

Full stack developer with a passion for UI/UX design. I create beautiful and useful digital products to solve people’s problem and make their life easy.

Hire Me