LearnAI ToolsCareerPractice BuildsPlayContact
Lesson 615 min read

Installing MongoDB & MongoDB Atlas

Set up a free MongoDB Atlas cluster and, optionally, a local MongoDB server for development.

Setting Up MongoDB Atlas

MongoDB Atlas is MongoDB's official managed cloud service, and the easiest way to get started — no local installation, no manual server management, and a permanently free tier (M0) suitable for learning and small projects.

Setup steps:

  • Create a free account at mongodb.com/cloud/atlas.
  • Create a new free (M0) cluster in a region close to you.
  • Create a database user with a username and password.
  • Add your current IP address (or 0.0.0.0/0 for learning purposes) to the network access list.
Restrict Network Access in Production

Allowing access from anywhere (0.0.0.0/0) is convenient for following along with this course, but a real production deployment should restrict network access to only the specific IPs or services that need it — covered further in the security lesson.

Getting Your Connection String

Atlas provides a connection string — a URL containing your cluster's address and credentials — used by the shell, Compass, or your application code to connect.

mongodb+srv://<username>:<password>@cluster0.abcde.mongodb.net/

Installing MongoDB Locally (Optional)

For fully offline development, MongoDB Community Server can be installed directly on your machine.

# macOS (via Homebrew)
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
# Then connect locally at:
# mongodb://localhost:27017

Common Beginner Mistakes

Forgetting to add your IP to Atlas's network access list

Without it, connections are rejected entirely — this is one of the most common first-connection issues.

Using special characters in a password without URL-encoding them

Characters like @ or : in a password can break the connection string's format — URL-encode the password, or choose one without special characters for simplicity.

FAQs

Yes — the M0 free tier fully supports everything covered here, including the aggregation framework and (with some version caveats) transactions.

Yes — MongoDB's query language and behavior are identical either way; only the connection string differs.

Summary

You now have a running MongoDB cluster, whether on Atlas or locally. Next, you'll explore it using the MongoDB Shell and Compass.

Next Lesson →

MongoDB Shell & Compass