https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/
xcode-select --install
Install brew using the official Homebrew installation instructions.
brew tap mongodb/brew brew update brew install mongodb-community@7.0
brew services start mongodb-community@7.0
brew services stop mongodb-community@7.0
For macOS running on Apple Silicon processors:
mongod --config /opt/homebrew/etc/mongod.conf --fork
To run mongod manually as a background process specifying --dbpath and --logpath on the command line, run:
mongod --dbpath /path/to/dbdir --logpath /path/to/mongodb.log --fork
To stop a mongod running as a background process, connect to the mongod using mongosh, and issue the shutdown command as needed.