Today we are going to learn how to install and launch MongoDB on macOS.
We are going to start with the prerequisites, MongoDB Installation, How to launch MongoDB and the Default configuration files.
MongoDB is a cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas.
In this tutorial, we are going to set up step by step MongoDB on macOS.
First of all, you need to verify is homebrew is already installed with the command :
brew -v // Output if it’s installed // Homebrew 2.4.15 // Homebrew/homebrew-core (git revision 872ea; last commit 2020-08-31)
To install it, we need to use the command below :
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
It can take a while to install just be patient.
For further documentation, you can check out this link.
First, we need to up brew dependencies with the command :
After we need to find the MongoDB Tap:
brew tap mongodb/brew
brew tap adds more repositories to the list of formulae that brew tracks, updates, and installs from. By default, tap assumes that the repositories come from GitHub.
We can install now MongoDB community Edition on our Computer using this command:
brew install mongodb-community
To have launchd start mongod immediately and also restart at login, use:
brew services start mongodb-community
To connect to mongodb use the command :
If there is an error
if for any reason you have an error, open a new terminal window and run the command:
wait for 15 seconds and then rerun the command
in another terminal.
The configuration file (/usr/local/etc/mongod.conf) The log directory path (/usr/local/var/log/mongodb) The data directory path (/usr/local/var/mongodb)