Table of contents
No headings in the article.
Open the Terminal app on your Mac.
Install Homebrew by running the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Check the zshrc file, hit 'cd' so that you will be in current directory then hit 'ls -la' which gives long listing and all the files which are hidden.Check whether .zshrc file is listed there or not.If not then hit 'vim .zshrc' and press i to get into insert mode and type ':wq' and hit enter, but maker sure after this you restart your mac or you can run this command source ~/.zshrc , so that it will make .zshrc file for you.
Once Homebrew is installed, update the Homebrew package list by running the following command:
brew update
- Install xcode by running the following command-
xcode-select --install
- Tap into the mongodb
brew tab mongodb/brew
- Install mongoDB by running the following command:
brew install mongodb-community@6.0
- Start the services of mongodb server
brew services start mongodb-community@6.0
- Stop the services of mongodb server
brew services stop mongodb-community@6.0
To run MongoDB (i.e. the
mongod
process) manually as a background process, run:--> For macOS running on Intel processors:
mongod --config /usr/local/etc/mongod.conf --fork
--> For macOS running on Apple Silicon Processors-
mongod --config /opt/homebrew/etc/mongod.conf --fork
- Install mongoshell
mongosh
- Now you can run all the mongodb commands,for example:
show dbs
That's it! With these steps, you should have successfully install mongodb on mac.