OneBite.Dev - Coding blog in a bite size

Install and run mongodb in Mac OS

How to install and run mongodb in mac with brew

Here is how I install mongodb in mac

Install MongoDB in mac

First, you need to install brew, the package manager.

Site: Brew

Add mongodb formula to brew

brew tap mongodb/brew

Now you can install mongodb with

brew install mongodb-community

Yes! it’s mongodb-community not just mongodb.

Start MongoDB in Mac

You can start MongoDB using brew services which will start the MongoDB server as a background service, meaning it will automatically start every time your system starts. To start it, run:

brew services start mongodb/brew/mongodb-community

Verify it’s running, with

brew services list

To stop the service

brew services stop mongodb/brew/mongodb-community

To connect to MongoDB use mongosh command

Reference:

mac mongodb