MongoDB is a popular NoSQL database that provides flexibility, scalability, and ease of use. In this blog post, we’ll walk through the step-by-step process of installing MongoDB on a Windows 10 machine.
Prerequisites
Before we begin, ensure that you have the following prerequisites:
- Windows 10: Make sure you’re running Windows 10 or a compatible version.
- Administrator Privileges: You’ll need administrative rights to install software on your system.
Step 1: Download MongoDB Community Edition
- Visit the MongoDB Download Center.
- Select the Windows 64-bit (8.1+) (MSI) option from the platform dropdown menu.
- Click the Download button and wait for the download to complete.
Step 2: Install MongoDB
- Locate the downloaded installer file (MSI) and double-click it.
- Follow the installation wizard instructions:
- Accept the license agreement.
- Choose the installation directory (you can keep the default).
- Select the components you want to install (MongoDB Compass, MongoDB Server, and MongoDB Tools).
- Click Install and wait for the installation to finish.
Step 3: Add MongoDB Bin Directory to System Path
After installation, add the MongoDB bin directory to your system’s PATH environment variable:
- Open the System Properties window (you can search for it in the Start menu).
- Go to the Advanced tab and click the Environment Variables button.
- Under System variables, find the Path variable and click Edit.
- Add the path to the MongoDB bin directory (e.g.,
C:\Program Files\MongoDB\Server\4.4\bin
). - Click OK to save the changes.
Step 4: Create a Data Directory
Create a directory where MongoDB will store its data. For example, create a folder named data in the root of your C drive (e.g., C:\data
).
Step 5: Start MongoDB
- Open the Command Prompt as an administrator.
- Navigate to the MongoDB bin folder using the
cd
command (e.g.,cd C:\Program Files\MongoDB\Server\4.4\bin
). - Run the following command to start the MongoDB server:
mongod.exe –dbpath C:\data
ReplaceC:\data
with the path to your data directory.
Step 6: Verify MongoDB Installation
- Open another Command Prompt window.
- Navigate to the MongoDB bin folder.
- Run the following command to connect to the MongoDB shell:
mongo
You should see the MongoDB shell prompt (>
). Congratulations! MongoDB is installed and running.
Conclusion
In this blog post, we covered the installation steps for MongoDB on Windows 10. Now you’re ready to explore MongoDB and build powerful applications. Happy coding! 🚀