How To Install MongoDB On Windows Operating System?
The MongoDB document-based database is open-source, cross-platform, and scalable. MongoDB Inc. developed it as a NoSQL database.
The name MongoDB comes from the word “humongous,” which means enormous.
The MongoDB database can store a large amount of data and perform quickly at the same time.
Step 1: Install MongoDB by downloading the MSI package
You can download MongoDB‘s current version here. Select MSI as the package you desire to download.
![Install MongoDB Install MongoDB](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-step1-1024x444.png)
![install mongodb setup downloading](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-setup-downloading.png)
Step 2: Install MongoDB
Read our article to learn how to install mongodb on linux.
Read our article to learn how to install mongodb on Mac.
- You must be logged in as a user with admin privileges. Once you have downloaded the .msi package, navigate to the downloads folder and double click it. You will be prompted to launch the installation wizard.
![Install MongoDB install mongodb setup downloaded](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-setup-downloaded.png)
- Start the installation by clicking Next.
![Install MongoDB install mongodb setup wizard step1](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-setup-wizard-step1.png)
- Click Next after accepting the licence agreement.
![Install MongoDB install mongodb setup wizard step2](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-setup-wizard-step2.png)
- The Complete setup option should be selected.
![Install MongoDB install mongodb setup wizard step3](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-setup-wizard-step3.png)
- Note the data directory and select “Run service as Network Service user” later on.
![Install MongoDB install mongodb setup wizard step4](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-setup-wizard-step4.png)
- You won’t need Mongo Compass, so deselect it and then click Next.
![Install MongoDB install mongodb setup wizard step5](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-setup-wizard-step5.png)
- Start the installation by clicking Install.
![Install MongoDB install mongodb setup wizard step6](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-setup-wizard-step6.png)
- It will only take a few minutes to complete the setup
![Install MongoDB install mongodb setup wizard step7](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-setup-wizard-step7.png)
- Once the installation is complete, click Finish.
![Install MongoDB install mongodb setup wizard step8](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-setup-wizard-step8.png)
Step 3: Organize our databases in data folders
The next step will be to set up MongoDB on the local system after the installation is complete.
- Create a new folder called data on the C Drive (c:) using Windows Explorer on your computer.
- Create a folder called db inside the data folder you just created in previous step.
![Install MongoDB install mongodb config step1](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-config-step1-1024x727.png)
Step 4: Setup Alias Shortcuts
- Copy the bin path to the location where MongoDB is installed on your system: C:\Program Files\MongoDB\Server\6.0\bin
- Click on System Properties > Environment Variables > System Variables > Path and Click Edit button to create an environment variable.
![Install MongoDB install mongodb config step2](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-config-step2-2-1024x598.png)
- Click New and paste the copied environment system link into Edit Environment Variable and click Ok.
![Install MongoDB install mongodb config step4](https://mrexamples.com/wp-content/uploads/2022/12/install-mongodb-config-step4-1024x612.png)
- The MongoDB server, mongod, will be run after the environment variable has been set. Open the command prompt and run the following command:
mongod
Step 5: Run mongo Shell
We will now connect our server (mongod) to the mongo shell.
- Keep the mongod window open and open a new command prompt window and type mongo. Mongod will now be successfully connected to our mongo shell.
- Don’t close the mongod window – closing this window will stop your server from functioning and it will be unable to connect with the mongo shell.
- The mongo shell is now ready for you to write queries.
- In your shell, you can now create databases, collections, and documents. Here is an example of how to create a new database.
- Use Database_name creates a new database in the system if it does not exist, or uses an existing database:
use mynewmongodb
You now have a database named mynewmongodb ready to use.
- Db.Collection_name creates a new collection in mynewmongodb, and insertOne() inserts the document into the firm collection:
db.firm.insertOne({Tesla:999})