Using mongosh, Compass, and Atlas UI for database management

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
CommandPurpose
show dbsList all databases
use <db>Switch or create a database
show collectionsList collections in current DB
db.stats()Show database statistics
db.help()List available database methods
exitClose the shell
Common Issue: MongoDB only creates a database once you insert at least one document into a collection within it. An empty 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

TaskBest Tool
Scripting and automationmongosh
Exploring unfamiliar data visuallyCompass
Managing cloud clustersAtlas UI
Quick one-off queriesmongosh or Compass
Performance monitoringAtlas UI
Pro Tip: Use mongosh for repeatable scripts you'll save and re-run, and Compass when you're exploring data for the first time — visual tools make patterns easier to spot.

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
Key Takeaway: mongosh, Compass, and Atlas UI aren't competitors — they're complementary tools. Professional MongoDB developers move fluidly between all three depending on the task.

Ready to master MongoDB?

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

Explore Course