For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Welcome to MongoDB Shell (mongosh)

The MongoDB Shell, mongosh, is a JavaScript and Node.js REPL environment for interacting with MongoDB deployments in Atlas, locally, or on another remote host. Use the MongoDB Shell to test queries and interact with the data in your MongoDB database.

Download mongosh
Abstract illustration showing a terminal interacting with different systems

What You Can Do

1

Find your connection string. The connection string varies depending on the type of deployment you're connecting to.

Learn how to find your connection string for Atlas.

Or connect to a self-hosted deployment.

2

Connect to a MongoDB deployment using the connection string.

The following connection string connects to an Atlas deployment:

mongosh "mongodb+srv://mycluster.abcd1.mongodb.net/myFirstDatabase" --apiVersion 1 --username <username>
3

Use your chosen connection type to view your data, import documents, and run queries.

For more information, refer to Perform CRUD Operations.

MongoDB Atlas Connect to your Database image

Learn More

CLI Icon

Use an external or built-in editor to work with multiline functions. Go beyond the line-oriented mongosh default console.

Unlock the Power of Editor Mode

MongoDB Shell Icon

Access session logs for any session within the last 30 days. Find the command syntax you can't quite remember, or look for common commands you can script.

Access Session Logs

Terminal Icon in a circle

Find out which methods mongosh supports. Get example syntax and parameter details for supported methods.

View Available Methods


Rate this page