MongoDB: How to install mongodb-community on Mac and run on localhost

The goal of this article is to show how to get mongodb-community to run on a Mac at localhost:27017. This assumes that Homebrew has already been installed on your Mac machine.

Using a terminal or bash window, start with the following brew command:
brew tap mongodb/brew

In this screenshot, I used this command after I already installed mongodb-community, so the command updates the associated taps:

Then use this command:
brew install mongodb-community

Once this is done, run the following command to run mongodb-community as a service:
brew services start mongodb-community

Then run the following command to test the mongodb installation:

For more details about these commands, see:

The default port for mongo is 27017, so if all is working properly we should get a mongo response on localhost at this port. For example: