Printing and PDF export are disabled for this content. View it online at Full Stack Learning Simplified.
Install MongoDB and Connectπ± Beginner
To develop with MongoDB, you can run a local instance using Docker, or (highly recommended) use MongoDB Atlasβa fully managed cloud database that gives you a production-ready cluster for free.
What is MongoDB Atlas?
MongoDB Atlas is the official cloud database service created by the makers of MongoDB. Instead of dealing with servers, firewalls, and updates yourself, Atlas hosts your database in AWS, Google Cloud, or Azure and gives you a simple connection string to plug into your app.
How to Install and Connect
Whether you use Docker or Atlas, you will interact with your database using mongosh, the modern, interactive JavaScript shell for MongoDB.
bash
# Option 1: Run a local instance instantly via Docker
docker run -d -p 27017:27017 mongo:8
# Connect to the local Docker instance
mongosh
# Option 2: Connect to a managed Atlas cluster in the cloud
mongosh "mongodb+srv://admin:password123@mycluster.mongodb.net"How to Use the mongosh Shell
Once connected, you can run administrative commands or execute database queries directly using JavaScript syntax:
| Command | What it Does |
|---|---|
show dbs | Lists all databases on the server. |
use shop | Switches to a database named 'shop' (creates it if it doesn't exist). |
show collections | Lists all collections within the current database. |
db.products.find() | Queries the 'products' collection and returns its documents. |
Pro Engineering Tip: While
mongosh is excellent for quick commands, download and install MongoDB Compass. It is the official, free GUI that allows you to visually browse documents, build complex aggregation pipelines, and analyze query performance without writing raw shell scripts.Free preview. Sign in and subscribe to unlock all 982 lessons across 31 courses.
Free preview Β· Β© 2026 Full Stack Learning Simplified