
MongoDB is a popular NoSQL database that provides a flexible and scalable way to manage data. If you’re a beginner Mongo DBA, understanding MongoDB basic commands is crucial for effective database management. In this guide, we’ll cover essential MongoDB commands with practical examples to help you get started. Let’s go through the mongodb cheat sheet :
Table of Contents
MongoDB Basic Commands with Examples :
Start/Stop MongoDB :
systemctl start mongod
systemctl stop mongod
Check Status of Mongodb:
systemctl status mongod
Output :

Connect to MongoDB Shell :
To start using MongoDB, open your terminal and enter the following command:
mongo
Check DB Version :
db.version()
Check Available Databases:
show dbs
Create or Switch to a Database:
use testdb
Check the Current Database:
db
Drop Database :
db.dropDatabase()
Output :

Create Collections in a Database:
Syntax :
db.createCollection("collection_name", options)
Example :
db.createCollection("new york")

Drop Collection :
Syntax :
db.collectionName.drop();
Example :
db.test.drop();
Output :

Hope this helps that you can get the MongoDB Basic Commands!! Also, you can get more information regarding mongodb commands with examples from the MongoDB Official Documentation as well :