In this post, we will see some MongoDB basic commands that will help us to manage our MongoDB instances.
Here, we can find all Mongo DB’s commands.
First of all, we connect to Mongo shell with the command mongo and then, we will start to run some commands:
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/1-5-1024x490.png)
SHOW DBS – It shows all databases
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/2-4.png)
USE “database name” – It selects or create a new DB
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/3-5.png)
DB – It shows the current selected database
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/4-4.png)
DB.CREATECOLLECTION(“collection_name”) – It creates a new collection in the selected db
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/5-1.png)
It is interesting know that until we don’t insert a collection in a new database, the database will not visible when we run the command show dbs.
For example, if we use a new db called test2db and then we run the command show dbs, this will be the result:
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/6-1.png)
Now, if we create a collection called Test and then we run show dbs again, this will be the result:
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/7.png)
SHOW COLLECTIONS – It shows all current database ‘s collections
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/8.png)
DB.”collection_name”.INSERT() – It inserts one document in a collection
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/1-6.png)
DB.”collection_name”.INSERTMANY() – It inserts many documents in a collection
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/2-5-1024x206.png)
DB.”collection_name”.FIND() – It shows the documents list
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/3-6.png)
DB.”collection_name”.REMOVE(‘criteria’) – It deletes one or more documents
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/4-5.png)
DB.”collection_name”.DROP() – It deletes a collection
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/5-2.png)
DB.DROPDATABASE() – It deletes the selected database
![](https://www.zoneofdevelopment.com/wp-content/uploads/2021/10/6-2.png)