Installation on Windows, macOS & Ubuntu
Download MongoDB Community Server from mongodb.com/try/download/community. Run the MSI installer, choose Complete setup, and optionally install MongoDB as a Windows service so it starts on boot.
Install on Windows
Download MongoDB Community Server from mongodb.com/try/download/community. Run the MSI installer, choose Complete setup, and optionally install MongoDB as a Windows service so it starts on boot.
Install mongosh separately if the installer does not include it — mongosh is the modern shell for running queries. Default data directory is C:\Program Files\MongoDB\Server\<version>\data.
Real-life example: Installing on Windows is like setting up a home printer — run the installer, plug in the defaults, then print a test page (mongosh ping) to confirm it works.
- Download Community Server MSI from official MongoDB site
- Install mongosh — the interactive shell (replaces legacy mongo CLI)
- Optional: MongoDB Compass GUI from mongodb.com/try/download/compass
- Ensure port 27017 is not blocked by firewall for local dev
# After install, open PowerShell or CMD
mongosh
# Inside mongosh
db.runCommand({ ping: 1 })
# { ok: 1 } means the server is reachableInstall on macOS with Homebrew
Homebrew is the simplest path on Mac. Tap the MongoDB brew repository, install mongodb-community, and start the service with brew services.
Real-life example: Homebrew install is like ordering a coffee kit subscription — one command delivers the beans (server) and mug (mongosh path) to your kitchen.
brew tap mongodb/brew
brew install mongodb-community@7.0
brew services start mongodb-community@7.0
mongoshInstall on Ubuntu with apt
Import MongoDB's GPG key and apt repository for your Ubuntu version, then apt install mongodb-org. Enable and start mongod with systemctl.
Real-life example: Ubuntu apt install is like registering with a local grocer — add their address (repo), then weekly delivery (packages) lands in your pantry.
# Follow current docs at mongodb.com/docs/manual/installation/
# Typical flow:
sudo apt-get install -y mongodb-org
sudo systemctl start mongod
sudo systemctl enable mongod
mongoshDocker quick start and verify with mongosh
Docker is the fastest way to run MongoDB without touching OS packages. One container exposes port 27017; exec into it for mongosh or connect from your host.
Real-life example: Docker MongoDB is a pop-up kiosk — open for business in seconds, tear down when class ends, no permanent renovation of your laptop.
docker run -d --name mongo -p 27017:27017 mongo:7
# Shell inside container
docker exec -it mongo mongosh
# Or from host (if mongosh installed locally)
mongosh "mongodb://localhost:27017"show dbs
use rishtaara
db.getName()
db.runCommand({ ping: 1 })