Install MongoDB Database on Windows

View more Tutorials:

1- Introduction

The document is based on:
  •  MongoDB 3.6.0

2- Note about versions

MongoDB for Windows Server 2008 R2 edition (i.e. 2008R2) runs only on Windows Server 2008 R2, Windows 7 64-bit, and newer versions of Windows. This build takes advantage of recent enhancements to the Windows Platform and cannot operate on older versions of Windows.

MongoDB for Windows 64-bit runs on any 64-bit version of Windows newer than Windows XP, including Windows Server 2008 R2 and Windows 7 64-bit.

MongoDB for Windows 32-bit runs on any 32-bit version of Windows newer than Windows XP. 32-bit versions of MongoDB are only intended for older systems and for use in testing and development systems. 32-bit versions of MongoDB only support databases smaller than 2GB.

3- Download

You can download the installment file (msi) or zip file. If you download zip file, you will just need to extract the compressed file without necessary installment. Then you start the configuration.
Note: MongoDB has 2 versions named as Community Server and Enterprice Server. Of which, the Community is the free version, and Enterprice is commercial one. In this post, I will guide you to set up and configure the free version.
Download results:

4- Install

Choose to install Mongodb Compass, this is a visual tool that helps you work with MongoDB.
OK, bạn vừa cài đặt xong MongoDBMongo Compass.

5- Configure MongoDB

This is folder you have installed (or unzip)
We create a folder containing the data of Database, a folder containing log file, and a configuration file, etc. For the best, put it in a safe drive instead of the C drive.
Create a folder:
  • D:/MongoStore
Next, create 2 subfolders
  • data
  • log
And create a configuration file:
  • config.txt
##store data

##all output go here
Now the configuration of MongoDB is successful. Next, we run MongoDB.

6- Run MongoDB

Here we run by CMD, but you can create a Service of window so that it can auto-start whenever window runs (See Appendix)
Open cmd and cd to the bin folder of mongodb.
cd C:\DevPrograms\MongoDB\bin
Command to start MongoDB:
mongod.exe --config D:\MongoStore\config.txt
If you receive the error below, see the fix at the end of this post.
Keep the CMD do not turn off.

7- Begin with MongoDB

After running MongoDB as the above step (Or let it auto-run as a service of Window), you open another CMD window for connecting with Database. In fact, you need a visual tool, but let try starting with MongoDB through CMD.
cd C:\DevPrograms\MongoDB\bin
Run mongo:
OK now you have to connect to the database test.
Execute commands on the CMD working with MongoDB:

8- Visualization tools to work with MongoDB

You need to install a visual tool for working with MongoDB database:

9- Appendix: Configuring MongoDB as a windows service

Open CMD and cd to bin folder of Mongodb. You need to open CMD under the authority of ADMIN.
cd C:\DevPrograms\MongoDB\bin
Next run the command:
mongod.exe --config D:\MongoStore\config.txt --install
Next, you open mongo.log file: 
Now on Window Service has service MongoDB.
You can start service on service explorer or start by CMD:
net start MongoDB

10- Appendix: Fix Error!

To fix this, you need to install the "Visual C ++ Redistributable", which you can download at the address below:

View more Tutorials:

Maybe you are interested

These are online courses outside the o7planning website that we introduced, which may include free or discounted courses.