How to Install MongoDB on Windows?

MongoDB is an open-source document-oriented database. It is categorized under the NoSQL(Not only SQL) database because the storage and retrieval of data in MongoDB are not in the form of tables. This is the general introduction to MongoDB now we will learn how to install MongoDB in Windows.

You can install MongoDB using MSI. Let’s see a step-by-step instruction guide for installing MongoDB in Windows using MSI.

Let’s see the MongoDB requirements for the installation of Windows.

Requirements to Install MongoDB on Windows

  • MongoDB 4.4 and later only support 64-bit versions of Windows.
  • MongoDB 7.0 Community Edition supports the following 64-bit versions of Windows on x86_64 architecture:
    • Windows Server 2022
    • Windows Server 2019
    • Windows 11
  • Ensure that the user is running mongod and mongos has the necessary permissions from the following groups:
    • Performance Monitor Users
    • Performance Log Users

Steps to Install MongoDB on Windows using MSI

To install MongoDB on Windows, first, download the MongoDB server and then install the MongoDB shell. The Steps below explain the installation process in detail and provide the required resources for the smooth download and install MongoDB.

Step 1: Go to the MongoDB Download Center to download the MongoDB Community Server.

Here, You can select any version, Windows, and package according to your requirement. For Windows, we need to choose:

  • Version: 7.0.4
  • OS: Windows x64
  • Package: msi

Step 2: When the download is complete open the msi file and click the next button in the startup screen:

Step 3: Now accept the End-User License Agreement and click the next button:

Step 4: Now select the complete option to install all the program features. Here, if you can want to install only selected program features and want to select the location of the installation, then use the Custom option:

Step 5: Select “Run service as Network Service user” and copy the path of the data directory. Click Next:

Step 6: Click the Install button to start the MongoDB installation process:

Step 7: After clicking on the install button installation of MongoDB begins:

Step 8: Now click the Finish button to complete the MongoDB installation process:

Step 9: Now we go to the location where MongoDB installed in step 5 in your system and copy the bin path:

Step 10: Now, to create an environment variable open system properties >> Environment Variable >> System variable >> path >> Edit Environment variable and paste the copied link to your environment system and click Ok:

Step 11: After setting the environment variable, we will run the MongoDB server, i.e. mongod.  So, open the command prompt and run the following command:

 mongod

When you run this command you will get an error i.e. C:/data/db/ not found

Step 12: Now, Open C drive and create a folder named “data” inside this folder create another folder named “db”. After creating these folders. Again open the command prompt and run the following command:

 mongod

Now, this time the MongoDB server(i.e., mongod) will run successfully.

Run mongo Shell

Step 13: Now we are going to connect our server (mongod) with the mongo shell. So, keep that mongod window and open a new command prompt window and write mongo. Now, our mongo shell will successfully connect to the mongod.

Important Point: Please do not close the mongod window if you close this window your server will stop working and it will not able to connect with the mongo shell.

Now, you are ready to write queries in the mongo Shell.

Run MongoDB

Now you can make a new database, collections, and documents in your shell. Below is an example of how to make a new database:

The use Database_name command makes a new database in the system if it does not exist, if the database exists it uses that database:

use gfg

Now your database is ready of name gfg.

The db.Collection_name command makes a new collection in the gfg database and the insertOne() method inserts the document in the student collection:

db.student.insertOne({Akshay:500})

Hence MongoDB is successfully installed and its working absolutely perfect! You can know more MongoDB in MongoDB: An introduction also learn more from MongoDB Tutorial by w3wiki!

Steps to Install MongoDB on Windows without Admin Rights

Here is Step by Step process on How to Install MongoDB on Windows without Admin Rights –

Step 1: Download the MongoDB ZIP archive from the official MongoDB website.

Step 2: Extract the contents of the ZIP archive to a location on your computer where you have write permissions, such as your user directory.

Step 3: Navigate to the extracted MongoDB directory and locate the “bin” folder.

Step 4: Open a command prompt window and navigate to the “bin” folder within the MongoDB directory.

Step 5: Run the MongoDB server by executing the command with the path to the directory where you want to store MongoDB data files. Make sure to use a location where you have write permissions.

Command: mongod.exe --dbpath=path\to\data\directory, replacing "path\to\data\directory"

Step 6: MongoDB should now be running locally on your Windows system without the need for admin rights. You can interact with MongoDB using the MongoDB shell by running the command mongo.exe in another command prompt window.

By following these steps, you can install and run MongoDB on Windows without admin rights, allowing you to work with MongoDB databases on your local machine.

Also Read:

Conclusion

In this article, we learned how to install MongoDB on Windows using MSI. We went through a step-by-step guide for downloading and installing MongoDB Community Server, setting up environment variables, and running MongoDB server and Shell.

Install MongoDB on Windows – FAQs

How to install MongoDB on Windows command line?

MongoDB can be installed on Windows command line by downloading the MongoDB ZIP archive from the official MongoDB website and extracting it to a location with write permissions. Then, navigate to the “bin” folder and run the MongoDB server using the command mongod.exe –dbpath=path\to\data\directory.

How to Install MongoDB on Mac?

To install MongoDB on Mac, you can use Homebrew by running the command brew install mongodb. Alternatively, you can download the MongoDB Community Server package from the official MongoDB website and follow the installation instructions.

How to Install MongoDB on Windows from ZIP?

MongoDB can be installed on Windows from ZIP by downloading the MongoDB ZIP archive from the official MongoDB website, extracting it to a location with write permissions, and running the MongoDB server using the command prompt.

How to install MongoDB on Windows Subsystem for Linux?

MongoDB can be installed on Windows Subsystem for Linux (WSL) by following the same installation steps as for Linux. You can download the MongoDB package for Linux from the official MongoDB website and install it on WSL using the terminal.

How to Install MongoDB on Windows 8.1 64-bit?

To install MongoDB on Windows 8.1 64-bit, you can use the same steps as installing MongoDB on other versions of Windows. Make sure to download the appropriate version of MongoDB for your operating system and follow the installation instructions provided in this guide.



Contact Us