MongoDB Local Setup Guide

Learn how to install and configure MongoDB on your local machine for development.

Installation on macOS

Install MongoDB using Homebrew:

# Install Homebrew if you haven't already
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install MongoDB Community Edition
brew tap mongodb/brew
brew install mongodb-community

# Start MongoDB service
brew services start mongodb-community

# Verify installation
mongosh

Installation on Windows

  1. Download the MongoDB Community Server from the official website
  2. Run the downloaded MSI installer
  3. Choose "Complete" installation type
  4. Select "Install MongoDB as a Service"
  5. Complete the installation
# Verify installation by opening MongoDB Shell
"C:\Program Files\MongoDB\Server\[version]\bin\mongosh.exe"

# Default installation directory
C:\Program Files\MongoDB\Server\[version]\

Installation on Linux (Ubuntu)

# Import MongoDB public GPG key
curl -fsSL https://pgp.mongodb.com/server-6.0.asc |    sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg    --dearmor

# Create list file for MongoDB
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

# Update package list
sudo apt-get update

# Install MongoDB
sudo apt-get install -y mongodb-org

# Start MongoDB
sudo systemctl start mongod

# Enable MongoDB on system startup
sudo systemctl enable mongod

# Verify installation
mongosh
MatureStack LogoBuilt with MatureStack