brew mongo db

# Step 1: Tap the MongoDB formulae
brew tap mongodb/brew

# Step 2: Install MongoDB
brew install mongodb-community

# Step 3: Start MongoDB as a background service
brew services start mongodb-community

# Step 4: Verify the MongoDB installation
mongo --eval "printjson(db.serverStatus())"

# Step 5: Connect to the MongoDB shell
mongo