Install MongoDB on Windows (Day 2)
Today, I will explain how to install MongoDB on Windows. You can read my previous MongoDB introduction article here:
Now, I will explain how to install MongoDB via a simple procedure.
Step 1
First, go to the MongoDB website and download an appropriate version of MongoDB for your system.
![Download MondoDB](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/Download MondoDB.jpg)
Step 2
After downloading the MongoDB installation package, run the MSI file.
![run the MSL file](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/run the MSL file.jpg)
Step 3
Accept the license.
![Accept License](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/Accept License.jpg)
Step 4
Choose the Setup Type.
![Choose Setup Type](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/Choose Setup Type.jpg)
Step 5
Install MongoDB.
![inatall MongoDB](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/inatall MongoDB.jpg)
Step 6
The following shows the installation process.
![Installation Process](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/Installation Process.jpg)
Step 7
The installation is complete.
![Installation Complete](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/Installation Complete.jpg)
After the successful installation of MongoDB, you will find that a folder named MongoDB has been created in your directory. You can find this folder here: C:\Program Files.
![created in your Directory](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/created in your Directory.jpg)
Step 8
After installation, now we set the path for MongoDB. For this, select the following path from your directory:
C:\Program Files\MondoDB\Server\3.0\bin.
Step 9
Now go to System Properties and press the Environment Variables button.
![select Environment Variable](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/select Environment Variable.jpg)
Step 10
Select the Path variable from the System variables.
![Select Path variable](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/Select Path variable.jpg)
Now paste this path here.
Step 11
Then, we create a default directory where MongoDB will save all its data. For this, open a command prompt and execute the following command.
![execute command](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/execute command.jpg)
Now you will find that the folder named data has been created in your C: directory, this folder contains another folder whose name is db. So far, the db folder is empty. In the future, all the data and the database will be stored here.
After all the preceding tasks we run the MongoDB server and client. First, close the opened Command Prompt and open it again.
First, run the “mongod” command. When you run this command the system will show many messages.
![mongod](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/mongod.jpg)
The MongoDB command is used to run a server at a specific port number. By default, this port number is 27017.
Now again go to the C:\data\db directory. You will find that some files and folders have been created automatically. All these files are generated by Mongod. Each file and folder has a specific task and use.
Open another command prompt window and run the mongo command.
![command prompt window](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/command prompt window.jpg)
The Mongo command is used to start a client. If you watch the previous command prompt (in which we ran the MongoDB command) you will find the following message:
This message shows that the number of active clients is one. If you open another command prompt and run the mongo command then you will find that the number of opened connections is two.
![command prompt](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/command prompt.jpg)
The installation and configuration has been completed.
Today we learned how to install MongoDB in Windows. In the next articles, we will start working on MongoDB. Until then, keep coding.
![installation](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/installation.jpg)
Step 9
Now go to System Properties and press the Environment Variables button.
![select Environment Variable](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/select Environment Variable.jpg)
Step 10
Select the Path variable from the System variables.
![Select Path variable](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/Select Path variable.jpg)
Now paste this path here.
![path](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/path.jpg)
Step 11
Then, we create a default directory where MongoDB will save all its data. For this, open a command prompt and execute the following command.
![execute command](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/execute command.jpg)
Now you will find that the folder named data has been created in your C: directory, this folder contains another folder whose name is db. So far, the db folder is empty. In the future, all the data and the database will be stored here.
After all the preceding tasks we run the MongoDB server and client. First, close the opened Command Prompt and open it again.
First, run the “mongod” command. When you run this command the system will show many messages.
![mongod](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/mongod.jpg)
The MongoDB command is used to run a server at a specific port number. By default, this port number is 27017.
Now again go to the C:\data\db directory. You will find that some files and folders have been created automatically. All these files are generated by Mongod. Each file and folder has a specific task and use.
![directory](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/directory.jpg)
Open another command prompt window and run the mongo command.
![command prompt window](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/command prompt window.jpg)
The Mongo command is used to start a client. If you watch the previous command prompt (in which we ran the MongoDB command) you will find the following message:
![Mongo command](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/Mongo command.jpg)
This message shows that the number of active clients is one. If you open another command prompt and run the mongo command then you will find that the number of opened connections is two.
![command prompt](https://www.csharp.com/UploadFile/Tutorial/admin/mondodb-day-2-install-mondodb-in-window29032020014628/Images/command prompt.jpg)
The installation and configuration has been completed.
Today we learned how to install MongoDB in Windows. In the next articles, we will start working on MongoDB. Until then, keep coding.
Next article >> Day 3 - MongoDB Database Basics
Author
Pankaj Kumar Choudhary
72
26.6k
13.5m