Lesson 2 / 22

Installing MongoDB & mongosh

Get MongoDB running locally and connect with the shell.

Install Community Edition

Free, open-source, and available for every major OS.

# macOS (Homebrew)
brew tap mongodb/brew
brew install mongodb-community

# Ubuntu: follow MongoDB's apt repo instructions
# Windows: use the official .msi installer

Start the server

mongod is the database server process — it listens on port 27017 by default.

brew services start mongodb-community
# or run directly:
mongod --dbpath /data/db

Connect with mongosh

mongosh is the modern interactive shell for running commands against MongoDB.

mongosh
# connects to mongodb://127.0.0.1:27017 by default

Output:

Current Mongosh Log ID: ...
Connecting to: mongodb://127.0.0.1:27017/
test>

MongoDB Compass

Compass is the official GUI — browse databases, run queries, and inspect indexes visually instead of typing everything.