MongoDB Shell and GUI Tools
MongoDB gives you multiple ways to interact with your data: the command-line mongosh, the visual MongoDB Compass GUI, and the browser-based Atlas UI. Knowing when to use each makes you dramatically more productive.
1. mongosh — The MongoDB Shell
mongosh is a modern, JavaScript-based command-line interface for interacting with MongoDB. It supports syntax highlighting, auto-completion, and full query capabilities.
// Connect to a local instance
mongosh
// Connect to Atlas
mongosh "mongodb+srv://cluster0.abcde.mongodb.net/myDatabase" --username myUser
// Show all databases
show dbs
// Switch to (or create) a database
use schoolDB
// Show collections in the current database
show collections
| Command | Purpose |
|---|---|
show dbs | List all databases |
use <db> | Switch or create a database |
show collections | List collections in current DB |
db.stats() | Show database statistics |
db.help() | List available database methods |
exit | Close the shell |
use myDB won't persist.
2. MongoDB Compass — Visual Exploration
Compass lets you browse documents, build queries with a visual filter bar, analyze schemas, and even build aggregation pipelines using a drag-and-drop stage builder.
- Schema Tab — Visualizes field types and value distributions across a collection.
- Explain Plan — Shows query performance and index usage.
- Aggregation Pipeline Builder — Build and preview pipelines stage-by-stage.
- Indexes Tab — Create, view, and drop indexes visually.
3. Atlas UI — Cloud Database Management
The Atlas web console offers cluster management, real-time performance monitoring, and a built-in Data Explorer for browsing collections directly in the browser — no local tools required.
- Metrics Tab — Real-time CPU, memory, and connection graphs.
- Data Explorer — Browse and edit documents in the browser.
- Performance Advisor — Suggests indexes based on slow query patterns.
- Triggers & Charts — Build event-driven functions and dashboards.
4. Choosing the Right Tool
| Task | Best Tool |
|---|---|
| Scripting and automation | mongosh |
| Exploring unfamiliar data visually | Compass |
| Managing cloud clusters | Atlas UI |
| Quick one-off queries | mongosh or Compass |
| Performance monitoring | Atlas UI |
5. Tooling Checklist
- ✅ Comfortable connecting via mongosh
- ✅ Know core shell commands — use, show dbs, show collections
- ✅ Explored Compass's schema and pipeline builder
- ✅ Familiar with the Atlas Data Explorer and Metrics tab
Ready to master MongoDB?
Build real-world MongoDB-powered applications with hands-on projects, mentor-led sessions, and placement support.