MongoDB – How to install it on macOS

In this post, we will see how to install and configure MongoDB on macOS.

First of all, we open the Terminal and run the command
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)” , in order to install Homebrew brew.

Then, we run the command brew tap mongodb/brew, in order to download the official Homebrew formulae for MongoDB and the Database Tools.

Finally, we run the command brew install mongodb-community@4.4, for installing MongoDb community edition.

We have done and now, with the command brew services start mongodb-community@4.4, we will run MongoDB as a macOS service:


For connecting to Mongo shell, we run the command mongo:


where, using the command show database, we can get the list of all databases in our MondoDB instance:


Finally, for stopping the MongoDB’s instance, we have to exit from the shell, using the command exit and then, we have to run the command brew services stop mongodb-community@4.4: