Home » MongoDB

How to initialize a database in MongoDB?

In this article, we are going to create or establish a database in MongoDB with MongoDB commands using mongo shell.
Submitted by Manu Jemini, on February 02, 2018

It is a non-sql database which we need to use to store data without using sql in it.

Using mongo is much easier then sql or mysql because of its basic formation of data and data management.

Any document in MongoDB is basically a JSON format, typically use to create reliability in data management.

How to run MongoDB server?

1) Open command prompt by typing cmd in search box.

2) Type mongod and press enter than wait for a second, there are some of the details get print on your command prompt like,

MongoDB - Initialize a database

Which shows your pid, port, dbpath and your host.

4) Port number given in the above picture is the port which is basically open for connecting to the MongoDB server.

5) Now run nother command prompt and type mongo to open mongo shell.

MongoDB - Initialize a database

6) Now type show dbs and you can see list of databases in your MongoDB.

MongoDB - Initialize a database

7) After that you can just use the database you want to, or create a new one by using similar command which is,

8) Use database_name and then press enter.

MongoDB - Initialize a database

9) Now you are using database vehicle which you created a moment before.

10) And there is also a command to show database you are working or using which is,

MongoDB - Initialize a database



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.