Installing MongoDB, MongoDB Atlas, and MongoDB Compass

Installation and Setup

Before writing a single query, you need a working MongoDB environment. This lesson covers three ways to get started: installing MongoDB locally, using the fully-managed MongoDB Atlas cloud service, and installing MongoDB Compass, the official GUI.

Recommendation: For beginners, MongoDB Atlas is the fastest way to start — no installation required, and it includes a free forever tier (M0 cluster).

1. Installing MongoDB Locally

Windows

  1. Download the MSI installer from mongodb.com/try/download/community.
  2. Run the installer and choose Complete setup type.
  3. Optionally install MongoDB Compass when prompted.
  4. MongoDB installs as a Windows Service and starts automatically.

macOS (via Homebrew)

brew tap mongodb/brew
brew install mongodb-community@7.0
brew services start mongodb-community@7.0

Linux (Ubuntu)

wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo systemctl start mongod
sudo systemctl enable mongod

2. Setting Up MongoDB Atlas (Cloud)

  1. Sign up at mongodb.com/cloud/atlas.
  2. Create a new Project, then click Build a Database.
  3. Select the M0 Free tier and choose a cloud provider/region.
  4. Create a database user (username + password).
  5. Under Network Access, add your IP address (or 0.0.0.0/0 for development).
  6. Click Connect to get your connection string.
mongodb+srv://username:password@cluster0.abcde.mongodb.net/?retryWrites=true&w=majority
Pro Tip: Never expose 0.0.0.0/0 network access in production. Restrict IP access to known servers or use VPC peering for secure connections.

3. Installing MongoDB Compass

MongoDB Compass is the official GUI for exploring and manipulating data visually.

  1. Download from mongodb.com/try/download/compass.
  2. Install and launch the application.
  3. Paste your connection string (local: mongodb://localhost:27017 or your Atlas SRV string).
  4. Click Connect to browse databases, collections, and documents visually.

4. Verifying Your Installation

mongosh
# Should open the MongoDB Shell and show the connection prompt
test> db.version()

5. Setup Checklist

  • ✅ Install MongoDB locally or create an Atlas cluster
  • ✅ Install mongosh (MongoDB Shell)
  • ✅ Install MongoDB Compass for GUI-based management
  • ✅ Whitelist your IP address if using Atlas
  • ✅ Test the connection using mongosh or Compass
Key Takeaway: Whether you install locally or use Atlas, get comfortable with both mongosh and Compass early — you'll use them constantly throughout this course.

Ready to master MongoDB?

Build real-world MongoDB-powered applications with hands-on projects, mentor-led sessions, and placement support.

Explore Course