Advance

How to install MongoDB on Windows

How to install MongoDB on Windows
1
(1)

How to install MongoDB on Windows. MongoDB Database is a very powerful database that is used at higher levels of software development and programming. It also has simple queries and is not difficult to work with for those who have professional experience in various programming projects.

In this article, we want to teach you how to install MongoDB on Windows, so that you can take advantage of the power of this database.

As you know, MongoDB is one of the most popular NoSQL databases that has many advantages and offers very good features to users.

 

Buy Windows Virtual Private Server

 

Step 1: Install MongoDB

1. To install this database, first enter the download page of MongoDB site and download the latest version.

2. After downloading, double-click on the desired file.

3. Accept its terms and conditions and click next.

4. In the next step, select the Complete mode and click on Install.

5. Click Finish at the end.

Recommended Article: How to install Apache Tomcat on Windows

Step 2: Add MongoDB to the global variables

Enter drive C to test that the installation was performed correctly. Then open the Program Files folder. You see a new folder called MongoDB has been added.

Now for a faster startup, it’s best to add MongoDB to the global variables of Windows. This is so you can open and work the database wherever you are using Command-Line or CMD.

To do this, you need to copy the path of the bin folder in MongoDB.

 

How to install MongoDB on Windows

 

In the Control Panel, click on Advanced system settings, and at the bottom, click on Environment variables:

 

How to install MongoDB on Windows

*

How to install MongoDB on Windows

 

Now double-click on Path:

After opening the Path information, click New. Then enter the copied path and click OK.

For example this path: C:\Program Files\MongoDB\Server\3.6\bin.

 

How to install MongoDB on Windows

 

Step 3: Create a data folder

In this step you have to create a folder for data in the root of drive C and put two folders db and log in this folder.

MongoDB stores the desired information in these folders by default.

 

Step 4: Run the server and connect to it

Run the MongoDB server. To do this, open CMD and type mongod and press Enter:

 

How to install MongoDB on Windows

 

You will see that the MongoDB server is running and now you need to open CMD and connect to it from other places and use it.

To do this, you can connect to this server from another CMD with the mongo command and work with the database. You can also do this with various software such as Robo Mongo.

Here we select the first way and open another CMD and type mongo and press enter:

 

How to install MongoDB on Windows

 

Step 5: Create the mongod.cfg configuration file

In this section you need to create a MongoDB service. By creating this service, every time your Windows is launched, the MongoDB server is also launched as a Windows service.

By doing this, the database is always active and you can use it.

To do this, enter the path where you installed MongoDB.

Such as C:\Program Files\MongoDB\Server\3.6. Then create a file called mongod.cfg and put the following code in it:

systemLog:  destination: file  path: c:\data\log\mongod.log  storage:  dbPath: c:\data\db

You can see that we specified the path of the folders created in the data here.

 

Step 6: Build the MongoDB service

Launch a CMD as Run as administrator and enter the following code in it and press Enter:

sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB\Server\3.6\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"

 

How to install MongoDB on Windows

 

The service was created successfully.

 

Step 7: Launch the MongoDB service

To do this, enter the following command in the same CMD that is open:

net start MongoDB

Here, if you have done the steps correctly, you will see that the MongoDB service has been successfully launched.

Now if you open the Task manager and enter the Services section, you will see MongoDB as shown below:

 

How to install MongoDB on Windows

 

The service status is Running. So every time the system comes up, MongoDB also starts automatically. Then you can connect and work in any way you want.

Use the following commands to stop and delete this service:

 // Stop serrvice  net stop MongoDB    // Delete service  sc.exe delete MongoDB  
Recommended Article: How to install MongoDB on Windows

Goodluck.

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

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

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day