How to install MongoDB on windows in 2024

  • mongodb
  • 207 Views
  • 4 Min Read
  • 2 May 2024

MongoDB is a Database Management System based on NoSQL (Not Only SQL) and utilizes JSON-like documents to store your data. Let's skip the introduction of MongoDB and head over to our topic: How to install MongoDB on Windows. This is a very straightforward guide about installing MongoDB locally on your Windows machine with the default configuration.

 

In order to use MongoDB Database, you can either opt for MongoDB Atlas, which is a managed cloud database service provided by MongoDB, or you can install it locally and access it using MongoDB shell (mongosh). Over time, MongoDB has made it simpler for us to install its database and access it.

 

 

System Requirement

 

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

 

MongoDB only supports the 64-bit versions of these platforms.

 

 

Install MongoDB Community Edition

 

Here, we're going to install MongoDB 7.0 Community Edition, which is free to use.

 

1. Download the .msi Installer

 

  • Click here to visit the downloads page of MongoDB.

 

  • Select the current version from the Version dropdown.

 

  • Select Windows from the Platform dropdown.

 

  • Select msi from the Package dropdown.

 

  • Proceed to Download.

 

If you want to proceed with the default settings, click here to start downloading (Recommended). It will start downloading the installer with default settings.

 

2. Running the Installer

 

Once you have successfully downloaded, go to the Downloads directory and double-click on the .msi installer file. This will open an installation wizard. Here, we're going to install MongoDB with the default configuration, so follow the below-mentioned steps:

 

  • Click on Next when the installation wizard appears.

 

  • Check the checkbox to agree to their terms and conditions, then click on Next.

 

  • Next, you'll be prompted with two options: Complete and Custom. Select Complete (Recommended) to install the default list of tools at the default path, or select Custom to install specific tools at a specific path. It's advisable to click on Complete to go ahead with the default setup.

 

 

How to install MongoDB in Windows in 2024

 

 

  • In the next step, you'll be asked for service configuration. You can install MongoDB as a service, so ensure that the Install MongoDB as a Service option is checked and Run Service as Network Service User radio is selected. Additionally, it'll create data and log directories automatically, so we don't need to create them manually. Then you click on Next. Refer to the following image:

 

 

How to install MongoDB in Windows in 2024

 

 

  • In the next step, uncheck the Install MongoDB Compass box if you don't want to install MongoDB Compass, which is a GUI (Graphical User Interface) that allows you to interact with database collections. It's totally according to your preference. Refer to the following image:

 

 

How to install MongoDB in Windows in 2024

 

 

  • Click on Next, and when ready, click on Install to start the installation process. Within a few minutes, it'll complete the installation process. Once finished, you can close the installation wizard.

 

In order to start a MongoDB instance and manage the database, we need a CLI (Command Line Interface) called MongoDB Shell, referred to as mongosh which is officially provided by MongoDB.

 

 

Install mongosh (MongoDB Shell)

 

It's quite easy to install and setup mongosh in Windows. Follow the below-mentioned steps:

 

1. Download the .msi Installer

 

  • Click here to visit the downloads page of MongoDB Shell.

 

  • Select the version from the Version dropdown.

 

  • Select Windows from the Platform dropdown.

 

  • Select msi from the Package dropdown.

 

  • Proceed to Download.

 

If you want to proceed with default settings, click here to start downloading (Recommended). It will start downloading the installer with default settings.

 

2. Running the Installer

 

Once you have successfully downloaded .msi file, go to the Downloads directory and double-click on the installer to open the installation wizard. In order to complete the installation of mongosh, follow along with these steps:

 

  • Click on Next when the installation wizard is ready.

 

  • In the next step, you'll be provided with the option to set the installation path. So let it be as it is and copy it for reference. This is the path where the mongosh executable will be installed. Then click on Next to proceed with installation. Refer to the following image:

 

 

How to install MongoDB in Windows in 2024

 

 

  • Click on Install when ready, and wait for a few minutes to complete the installation process. When finished, you can close the installation wizard.

 

Now we've successfully installed both MongoDB and MongoDB Shell to interact with it. Before we test them, we need to add the path of the mongosh.exe binary to the PATH Environment Variable. If you didn't copy the path during the installation of MongoDB Shell, press 'Window + R' in your Windows machine, type 'AppData', and hit enter. Then navigate to /Local/Programms/mongosh. Visit this location and copy the path.

 

3. Adding mongosh path to the PATH variable

 

In order to add mongosh executable to the PATH environment variable, follow these steps:

 

  • Copy the path of the mongosh directory.

 

  • In Windows, search for Edit the system environment variables in the Start menu.

 

  • Click on Environment Variables... in the dialogue.

 

  • Under System Variables, search for the path variable, select it, and click on Edit. This will open another dialogue.

 

  • Click on New and paste the path of the mongosh executable that you copied.

 

  • Click on Ok and close all the dialogues.

 

If the given steps are confusing, refer to the following GIF image for better understanding:

 

How to install MongoDB in windows in 2024

 

 

Testing MongoDB

 

Once you add the path of mongosh executables to the PATH environment variable, open a terminal (restart if already opened) and type the following command:

 

mongosh

 

When you run this command, you'll see MongoDB is running, and you'll be able to interact with it using the CLI. Upon running the above command, you'll see the output as shown in the following image:

 

 

How to install MongoDB in windows in 2024

 

 

If you're seeing output like the one given above, that means you've successfully installed MongoDB and MongoDB Shell on Windows. It's now running on localhost at mongodb://localhost:27017. You can copy-paste this URL into your code as a database URI to use MongoDB locally. Additionally, in order to interact with your database using the GUI, you can connect with MongoDB Compass using the mongodb URI.

 

 

Conclusion

 

By following the above steps, I hope you have successfully installed MongoDB and MongoDB Shell. You can now use it as a local database while building applications and websites. You can now explore how to execute database operations such as inserting, reading, updating, deleting, etc. using mongosh. For a GUI experience, connect your database with MongoDB Compass. 

 

If this tutorial helps you through the installation of MongoDB, make sure to share it with your friends or community. Additionally, you can write your feedback in the comment section about what can be improved.

Didn't find your answer? Add your question.

Share

Comments (0)

No comments yet. Be the first to comment!

About Author

Username

Vanvir Singh Devda ( vanvirsinh )

Full Stack Developer | MERN Stack

Joined On 12 Feb 2024

More from Vanvir Singh Devda

How to Upload Code to GitHub: Quick Steps and Detailed Instructions for Beginners

github

16 Sep 2024

In order to upload (push) your project to GitHub, it involves multiple steps that need to ....

How to create working responsive navbar with multilevel dropdown menu in React Js

react-js

9 Jul 2024

Have you ever found yourself stuck in the complexity of creating a working and responsive ....

Exploring What Web Developers Need to Know For The Future

web-development

17 May 2024

The entire world is experiencing a technological revolution, and web development as a crea....

 10 JavaScript String Methods You Must Know

javascript

9 May 2024

JavaScript provides several methods for manipulating strings. These include splitting stri....

How to install MongoDB on windows in 2024

mongodb

2 May 2024

MongoDB is a Database Management System based on NoSQL (Not Only SQL) and utilizes JSON-li....

JavaScript concepts for beginner web developer

javascript

9 May 2024

This tutorial is going to be very helpful specially for beginners in JavaScript. Throughou....

Popular Posts from Code Mafias

10 Fun Websites for Stress Relief and Relaxation During Coding Breaks

programming

11 Nov 2024

Top 10 fun websites for coders to relax during breaks. Recharge with interactive games, ar....

Mastering HTML: Top 12 Unique HTML Tags with Examples

html

4 May 2024

Through this article, learn those essential HTML tags that many developers do not know abo....

Top 60 Eye-Catching Button Designs Users Can’t Wait to Click - With Source Code

ui-ux

11 Oct 2024

Discover 60 eye-catching button designs with source code, crafted with HTML and CSS to enh....

How to Upload Code to GitHub: Quick Steps and Detailed Instructions for Beginners

github

16 Sep 2024

In order to upload (push) your project to GitHub, it involves multiple steps that need to ....

How to install MongoDB on windows in 2024

mongodb

2 May 2024

MongoDB is a Database Management System based on NoSQL (Not Only SQL) and utilizes JSON-li....

How to Implement Undo Functionality for Deleting Items in Your React App

react-js

28 Sep 2024

Learn how to implement undo functionality for deleting items in React. Follow a step-by-st....