how to create database in mongodb?

Today, We want to share with you how to create database in mongodb.In this post we will show you mongodb create database with username and password, hear for create collection in mongodb we will give you demo and example for implement.In this post, we will learn about MongoDB CRUD Tutorial With Example From Scratch with an example.

MongoDB Create Database

there are Installing MongoDB creates 3 default main databases:

  • Admin
  • Config
  • Local

The use Command

Basic syntax



>use mydb
switched to db mydb

Get databases list

>show dbs
local     0.78125GB
pakainfo      0.23012GB

Creating a MongoDB Database with the CLI

> show dbs
admin 0.000GB
local  0.000GB

Start the MongoDB service

net start MongoDB

The MongoDB service is starting..
The MongoDB service was started successfully.

Read Also:  Laravel 6 insert query Example

creating a collection user and inserting a document in it.

> db.user.insert({name: "Chaitanya", age: 30})
WriteResult({ "nInserted" : 1 })
> show dbs
admin          0.000GB
pakainfowebdo  0.000GB
local          0.000GB

Creating a Collection/Table using insert()

The Field Names of the document are “Memberid” and “MemberName” and the Field values are “1” and “Meera’ respectively. A bunch of documents would then make up a collection in MongoDB.

		"Memberid" : 1,
		"MemberName" : "Pankitsh"

I hope you get an idea about how to create database in mongodb.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  Simple Laravel Dynamic Select Boxes Example

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *