How to show collections in MongoDB? How to exit MongoDB shell mongosh ? How to describe all tables in a MongoDB database? Find all the answers in our MongoDB cheat sheet
We gathered a list of handy MongoDB and mongosh commands and queries when working with MongoDB databases. Please ping us @ForestAdmin if you’d like to add something to the cheat sheet!
This is the second post from our Cheat Sheets series following the PostgreSQL one.
Getting started with MongoDB
Login and enter MongoDB Shell mongosh
List MongoDB databases
Connect to MongoDB database
Exit MongoDB Shell mongosh
Managing MongoDB
Check MongoDB version
Check if MongoDB is running
Restart MongoDB on Linux
Restart MongoDB on Mac OSX
Restart MongoDB on Windows
Change MongoDB user password
Exit from mongosh
Interacting with MongoDB databases
List MongoDB databases
Connect or switch to MongoDB database
Create new MongoDB database
Show name of the current database
Delete MongoDB database
Rename MongoDB database
Interacting with MongoDB collections
List MongoDB collections
Describe MongoDB collection
Describe all collections in MongoDB database
Create MongoDB collection
Delete MongoDB collection
Rename MongoDB collection
Interacting with MongoDB indexes
List MongoDB indexes in a collection
Create a MongoDB index in a collection
Create multiple MongoDB indexes in a collection
Delete MongoDB index
Delete all indexes in MongoDB collection
Rebuild MongoDB indexes
Interacting with MongoDB documents
Count documents in a MongoDB collection
List all documents in a MongoDB collection
Create document in MongoDB
Display a document in MongoDB
Update a document in MongoDB
Delete a document in MongoDB
Replace a document in MongoDB
Backup and restore MongoDB database
Backup MongoDB database
Restore MongoDB database
Managing roles, users and permissions in MongoDB
List MongoDB roles
Create MongoDB user
Delete MongoDB user
Change MongoDB user password
Need to build admin panels or a GUI tool for MongoDB? Check out Forest Admin for MongoDB
