xxxxxxxxxx
Download Xcode Command Line tools.
xcode-select --install
Allow Homebrew to add and access MongoDB:
brew tap mongodb/brew
Update Homebrew:
brew update
Install MongoDB Community Edition (@6.0 is the latest version at the time of this post):
brew install mongodb-community@6.0
macOS with Intel processors:
mongod --config /usr/local/etc/mongod.conf --fork
macOS with Apple M1 processors:
mongod --config /opt/homebrew/etc/mongod.conf --fork
Then open the shell:
mongosh
Or just run mongod.
xxxxxxxxxx
# Open the Zsh configuration file
$ vi ~/.zshrc
# Add the MongoDB binaries directory to the PATH
export PATH="/path/to/mongodb/bin:$PATH"
# Save and exit the file (in vi, press ESC and type :wq)
# Reload the Zsh configuration
$ source ~/.zshrc
# Now try running mongod again
$ mongod