Creating a Database in Mongodb
Mongodb Is a Nosql Database. That Means the Way We Work in Mongodb Is Different from That of a Relational Database Like Mysql. If You Are Coming from an Rdbms...
MongoDB is a NoSQL database. That means the way we work in MongoDB is different from that of a relational database like MySQL. If you are coming from an RDBMS background, you will be quite comfortable with this topic.
Surprisingly, however, MongoDB doesn’t have a ‘create database’ operation to create a database as you do in SQL. So, in this article, let’s explore how to work with databases in MongoDB.
(This article is part of our MongoDB Guide. Use the right-hand menu to navigate.)
Installing MongoDB
If you haven’t installed MongoDB yet, let’s do it first. Download the MongoDB package suitable for your OS. Download the msi/zip file compatible with your OS and install the application. (I am not going to describe the installation process in detail, as it is straightforward.)
I assume now you have installed the MongoDB database successfully. Open your CMD and type mongod –version to verify your installation. If you get an output similar to the result in the picture below, everything is perfect.
Must Read
Accessing the Mongo shell
When you install MongoDB, a CLI tool called Mongo shell will be installed along with it. You can use it to give commands to the MySQL server. In order to get access to the mongo shell, you have to start the server with the following command:
net start MongoDB
If you get this output, the MongoDB server has successfully started:
Next, we should run the MongoDB shell. To do that, type the command mongo in the CMD.
Now you are in the MongoDB shell, where you can execute commands to:
- Create databases
- Insert data
- Edit and delete data from databases
- Issue administrative commands