← Back to MongoDB Course | Chapter 1: Introduction | Lesson 6 of 7

MongoDB Atlas

Atlas is MongoDB's hosted cloud service, so you get a database without installing or managing servers.

In this page:

  1. MongoDB Atlas
Syntax
javascript
mongodb+srv://username:[email protected]/database_name
mongosh "connection_string"

MongoDB Atlas

Create a free cluster on cloud.mongodb.com, add a database user, allow your IP address in Network Access, and copy the connection string. The mongodb+srv scheme finds the cluster through DNS. Atlas handles backups, scaling and upgrades.

Note: The free M0 tier is enough for learning and small projects.

Example: MongoDB Atlas

bash
$ mongosh "mongodb+srv://cluster0.abcde.mongodb.net/shop" --username appUser
Enter password: ********
Atlas atlas-abc123-shard-0 [primary] shop>

// In Node.js, keep the string in an environment variable
const uri = process.env.MONGODB_URI;   // mongodb+srv://appUser:<password>@cluster0.abcde.mongodb.net/shop

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
Common Mistakes
  1. Forgetting to allow your IP address
  2. Committing the connection string with the password
  3. Using the wrong database user
Chapter Summary
  • Atlas is hosted MongoDB
  • Create a cluster and a database user
  • Allow your IP in network access
  • Connect with a mongodb+srv string
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.