How to use MongoDB Shell
1. Start MongoDB Shell
mongosh2. Check the MongoDB Version
db.version()3. Show Available Databases
show dbs4. Create or Switch to a Database
use testDB5. Create a Collection and Insert Documents
6. Retrieve Data
7. Update Documents
8. Delete Documents
9. Drop a Collection
10. Exit MongoDB Shell
Final Output Example
Last updated