Reading Time: < 1 minute

HI all, this document shows you how to remove all data from specific MongoDB collections.
MongoDB is NoSQL database, MongoDB uses JSON-like documents with optional schemas.
Sometimes there will be a requirement to delete all the data of specific MongoDB collection.
Here we will provide the steps for that.

Step 1: log in to mongo shell

mongo

Step 2: Now choose your database,

>show dbs

admin
vault
scrapper
>use scrapper

Step 3: now display your collections under scrapper database,

> show collections

mail
user
joinings

Step 4: Now delete all the data from user collection.

 

db.user.remove({})

Success, now you deleted all the data from user collection. this will keep the collection in the MongoDB but it will delete all the data under the user collection.

thank You!!!!

© 2020, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points

Prabhin Prabharkaran

He is Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!!

0 Comments

Leave a Reply