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
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