MongoDB is most easily installed on MacOS by using Brew, a package manager for macOS that can be used to install, update, and manage software packages on your system. Brew is commonly used to install open-source software, such as MongoDB.
To install MongoDB using Brew, you will first need to install Brew on your system, if it is not already installed. You can do this by following the instructions on the Brew website.
Once Brew is installed, you can use the brew
command to install MongoDB by running the following command in a terminal window:
brew install mongodb
This will install the latest version of MongoDB on your system. Brew will also automatically manage the MongoDB server and start it whenever you log in to your system.
To start the MongoDB server manually, you can use the brew services
command, like this:
brew services start mongodb
To stop the MongoDB server, you can use the brew services
command with the stop
option, like this:
brew services stop mongodb
Brew also makes it easy to update MongoDB to the latest version. To update MongoDB using Brew, simply run the following command:
brew upgrade mongodb
Brew will automatically update MongoDB to the latest version and restart the MongoDB server.
In summary, using Brew to install MongoDB on macOS is a convenient and easy way to set up a local MongoDB development environment on your system. Brew automatically manages the MongoDB server and makes it easy to update MongoDB to the latest version.
Selecting a Specific Version
The steps above will install the latest stable release of MongoDB. If you want to install a specific version of MongoDB, you can use the brew search
command to find available versions, and then specify the version you want to install using the brew install
command. For example, to install version 4.2.6 of MongoDB, you would run the following commands:
brew search mongodb brew install mongodb@4.2.6