MongoDB is a fully flexible index support and rich queries database. It is a NoSQL database. MongoDB 4.0 supports multi-document ACID transactions. This tutorial will help you to install MongoDB database server on macOS. After the installation, you may also like our MongoDB tutorial.
- Terminal: You must have macOS terminal access and little knowledge about working with the command line.
- Homebrew: Homebrew is a popular package management tools used for installing most open source software like Node. Here is the Homebrew installation tutorial
Install MongoDB on MacOS
First of all, update the Homebrew package repository index. Then install MongoDB using homebrew installer. This will install MongoDB at location /usr/local/Cellar/mongodb.
brew update brew install mongodb
Start MongoDB – Use the following command to start MongoDB from a terminal. Make sure to change 4.0.3_1 in below command with the installed version of MongoDB on your macOS.
launchctl load /usr/local/Cellar/mongodb/4.0.3_1/homebrew.mxcl.mongodb.plist
Stop MongoDB – Simply use the unload options to stop running MongoDB database service on macOS.
launchctl unload /usr/local/Cellar/mongodb/4.0.3_1/homebrew.mxcl.mongodb.plist
Working with MongoDB
After starting MongoDB service, just type “mongo” on the terminal. This will connect to MongoDB service running on the local system.
You can visit our MongoDB tutorial section to read and understand working with MongoDB.