A collection is a grouping of MongoDB documents. Documents within a collection can have different fields. A collection is the equivalent of a table in a relational database system. A collection exists within a single database


  1. Database name
  2. Database user name
  3. Database password
  4. A user with sudo privileges for SSH connection


Step 1: SSH the server where the Mongo database is running

$ ssh user@IP

Step 2: Log in to the Mongo database

$ mongo

Step 3: List the databases and switch to the required database where we need to clear the data

$ show dbs;
$ use <DB-name>

Step 4: List the collections

$ show collections

Step 5: Clear the data from the collection with the below query without deleting that collection from the database

$ db.collection-name.deleteMany({})

Leave a Reply