Mac InstallationLesson 2
Author : Afrixi
Last Updated : February, 2023
To install MongoDB on a Mac, follow these steps:
Open the Terminal app on your Mac. You can find it in the Applications/Utilities folder or by searching for “Terminal” in Spotlight.
Use the following command to install Homebrew, a package manager for macOS:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once Homebrew is installed, use the following command to install MongoDB:
brew install mongodb-community
After the installation is complete, create a directory for MongoDB to store its data:
sudo mkdir -p /data/db
Change the permissions of the directory to allow access:
sudo chown -R `id -un` /data/db
Start the MongoDB server by running the following command in your terminal:
MongoDB should now be running on your machine. You can connect to it using the MongoDB shell by running the following command in a new terminal window:
That’s it! You now have MongoDB installed and running on your Mac.