Creating and Deleting MongoDB Database

Creating and Deleting MongoDB Database

Instructor-svgAl-Mamun Sarkar
Sep 11 , 2020

In this lesson, I will show you how to create a database on MongoDB as well as how to delete a database from the MongoDB server. 

 

Run mongo command to enter into mongo shell:

mongo

 

Create Database:

Syntax:

use database_name

Example:

use school

 

Insert data to a collection:

db.users.insert({"name":"Mamun", "email": "mamun@gmail.com"})

 

Drop Database:

Go to the database by running the following command.

use school

Delete the database:

db.dropDatabase()

Output:

{ "dropped" : "school", "ok" : 1 }

 

Show databases:

show dbs

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram