Install MongoDB Windows



To install MongoDB, you need to have a 64 bit Windows based operating system e.g. Windows Server 2008, Windows 7 or later. Choose the latest release for your host environment from the MongoDB website. The installer contains everything you need for installing and using MongoDB e.g. MongoDB server (mongod), MongoDB client (mongo), MongoDB backup and restore tools (mongodump, mongorestore), and a few more.

After downloading the correct version of MongoDB, start the installer by double-clicking the downloaded file and click next to proceed. Read the License agreement, accept the agreement document and click next

Install MongoDB Windows

We are installing the full version of MongoDB so click on the Complete, show in the dialog box.

Install MongoDB Windows

Start the installation process by clicking on the Install button from the dialog box appeared after Complete selection.

Install MongoDB Windows

The installation process is complete, click Finish button. MongoDB has been installed in the default location of the computer which is C:\Program Files\MongoDB. Now, set the system environment variable PATH for the executables files of MongoDB. Step are as follows:
Open run Dialog box and type “SystemPropertiesAdvanced” From the dialog box opened, click on Environment Variables. Append to the location of MongoDB bin directory in PATH variable under system variables.
System Variable

Configure MongoDB as a Windows service

Create directories where you want to store data and logs for MongoDB and also create a file in MongoDB home directory, with the following content

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

Command to creat directory:

#you may use mkdir or md command to create directory.
mkdir D:\data\log\
md D:\data\db

Open cmd with Administrator by pressing WIN+X from the keyboard in Windows 10 and select Command Prompt (Admin). In cmd terminal run following command

  mongod --config <path to the configuration file>  --install

Now open services and start the MongoDB. To test that MongoDB is installed successfully, open a cmd terminal and execute mongo command to connect the client shell of the locally running server.


MongoDB for Beginners

MongoDB for Beginners