Conventional relational database management systems make it tough to scale data warehousing, grid, web 2.0, and cloud applications. Their non-linear question execution time, unstable question plans, and static schemas are a huge disadvantage and make data management a strenuous task. As a result, the servers fail to update and retrieve data as per expectations. MongoDB, a document-oriented database server, solves all these problems by offering unbeatable service at speeds that modern technologies demand.
MongoDB is a popular distributed database that supports replication, horizontal partitioning (sharding), a flexible document schema, and ACID guaranteed on the document level. Moreover, the support for Ad-Hoc queries, flexibilities, auto sharding and auto-failover, schema-free migration, effective horizontal scalability, and access to professional technical support makes the database the most favourite among programmers worldwide.
To download and install MongoDB successfully on your computer, you must have the minimum requirements to avoid errors in your installation process.
The hardware and the software requirements you need for installing MongoDB are stated below:
- RAM 4GB
- CPU Intel Core i3TM i3 HQ CPU @2.50 GHz
- ROM 256 GB
- Any browser like Google Chrome, Mozilla Firefox, or Microsoft Edge.
Let us look at the step-by-step approach on how to install, set-up, and configure MongoDB in Windows 10.
Step-1: Download the installer.
Download MongoDB Community (.msi) file installer from the link below:
Now go to the official MongoDB site and click on Community Server as shown:
In the Version dropdown, select the version of MongoDB to download as shown:
a. In the Platform dropdown, select Windows.
b. In the Package dropdown, select msi. (Mark it as the most crucial step.)
c. Click Download.
Based on your internet speed, the MongoDB msi installer may take time to download in your system.
Once you have successfully downloaded MongoDB on your system, it’s time to specify where you want to store the set-up code. Specify the location you want to keep the MongoDB Windows installer package. For example, here we are storing the package in the Local Disc (F:) in our system.
Step-2: Run the MongoDB installer.
Now, its time to run the application in your system. Run the application by following the simple steps:
a. Go to the directory where you downloaded the MongoDB installer (.msi file). By default, this is your Downloads directory.
b. Double-click the .msi file.
Step-3: Click on Next
You will get a welcome message from the MongoDB Community Edition installation wizard. The set-up wizard will guide you through the installation of MongoDB in your system. To continue with the installation process, click on Next.
Step-4: Read the End-User License Agreement
Adhere to the terms of using the software. Read the end-user license agreement carefully before proceeding further.
Step-5: Accept the terms
Once you have read the terms and conditions mentioned by the MongoDB community, click on the square box as shown below. Further, click on the Next button to continue.
Step-6: Choose Setup Type – Complete
Once you land on the choose set-up type page, choose the option as Complete and then click the Next button.
Attention: MongoDB allows you to choose either the Complete (recommended for most users) or Custom (to customize the set-up type you desire) buttons.
Step-7: Keep Service Configuration as default.
N.B.: Don’t make any changes here and keep all these parameters as default. Click on the Next button.
Data directory: Select the data directory, which leads you to the –dbpath. In case this directory does not exist, the installer will create the directory automatically and set the directory access to the service user.
Log Directory: Select the Log directory, which is similar to the –log path. If the directory does not exist, the installer will create the directory automatically and set the directory access to the service user. All this is done automatically.
Install MongoDB as a Service.
Service Name: MongoDB
Data Directory: C:Program FilesMongoDBServer4.4data
Log Directory: C:Program FilesMongoDBServer4.4log
Attention: Note that if you already have a customized name service, you must choose another name.
Run the service as a local or domain user.
For an existing local user account, specify a period (i.e..) for the Account Domain and specify the Account Name and the Account Password for the user.
For an existing domain user, specify the Account Domain, the Account Name, and the Account Password for that user.
Step-8: In the next step you will get an option to install MongoDB compass. Ignore and click on the Next button.
Step-9: Click on Install
Once you land on the Ready to Install MongoDB page, click on Install as shown below. Once done, the MongoDB installation begins.
The installation now starts. Based on your system speed, the installation may take a few minutes, and you are expected to get an image as shown:
Step-10: Click the Finish button.
The finish button will exit the Setup Wizard. On clicking the finish button, the installation gets completed.
Congratulations! You have successfully installed MongoDB and set up MongoDB in your local system.
Go to file location of MongoDB and copy the path of MongoDB bin directory as shown below:
- Open Windows Command Prompt
- Run as administrator
Now type cd to change the directory path to the desired path as shown below:
cd c:Program FilesMongoDBServer4.4
After typing mongo, press enter. You will get to see the image below:
To check the databases, type show databases as shown below:
If you want to know the admin, type use admin as shown below:
To check the collection in the database, type show collections as shown below:
Checking the Version
Once you have downloaded MongoDB in your system, use the below command to check the version of MongoDB installed in your system.
Attention: You may have noticed that we have not yet specified the path for our environment variable, which is why we have to manually type C:Program FilesMongoDBServer4.4 to run MongoDB in our system.
Setting the path to Environmental Variable
Step-1: Go to my computer, right-click and choose the option as properties.
Step-2: Choose the advanced system settings option in the top left as shown:
Step-3: Now go to Environment variables as shown below:
Step-4: Go to system variables and choose the option path as shown below:
Step-5: Add the C:Program FilesMongoDBServer4.4 and press OK.
Now you can see, we are able to run MongoDB without bringing the C:Program FilesMongoDBServer4.4
Creating a demo database:
Till now we have seen how to set up and install MongoDB in our system. Now let us see a demo on how to create a database in MongoDB.
Step-1: Go to the command prompt and type mongo.
Step-2: After opening MongoDB prompt, create a new database with the name KnowledgeHutGlobal using the following command:
Use KnowledgeHutGlobal and add data into the collection.
Step-3: Showing database in the collection
Let us see how to uninstall MongoDB from the system. To uninstall MongoDB from our system, we need to follow the following steps as discussed below:
Step-1: Go to the control panel.
Step-2: Choose the option: Uninstall a program.
Step-3: Select MongoDB from the list.
Step-4: Right Click on MongoDB and you will find three options as shown below:
Step-5: Click on uninstall and complete the uninstallation process.
That’s all! You will have successfully uninstalled MongoDB from Windows 10.
Go to your Windows command prompt and run the command to check the version of MongoDB in your system.
You will get an error message because you have uninstalled MongoDB from the system.
MongoDB has unparalleled and unique advantages over SQL-based databases because it allows data replication to mirror servers with full flexibility and reliability. Plus, the installation process is not complicated and can be completed with ease by following the step-by-step instructions mentioned above.
Just keep in mind that the MongoDB installers come in both 32-bit and 64-bit format. Based on your work requirement and your system configuration, choose the format to cater to your database needs. If your work involves more testing and development, then a 32-bit installer is definitely recommended. However, the 32-bit installer is not a perfect choice for production environments as this type of format limits the amount of data stored in the database. Perhaps, you must opt for a 64-bit installer in your system to get the most of MongoDB.