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

Install MongoDB
Install MongoDB
install mongodb setup downloading

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.

install mongodb setup downloaded
Install MongoDB
  • Start the installation by clicking Next.
install mongodb setup wizard step1
Install MongoDB

 

  • Click Next after accepting the licence agreement.
install mongodb setup wizard step2
Install MongoDB
  • The Complete setup option should be selected.
install mongodb setup wizard step3
Install MongoDB

 

  • Note the data directory and select “Run service as Network Service user” later on.
install mongodb setup wizard step4
Install MongoDB

 

  • You won’t need Mongo Compass, so deselect it and then click Next.
install mongodb setup wizard step5
Install MongoDB

 

  • Start the installation by clicking Install.
install mongodb setup wizard step6
Install MongoDB

 

  • It will only take a few minutes to complete the setup
install mongodb setup wizard step7
Install MongoDB
  • Once the installation is complete, click Finish.
install mongodb setup wizard step8
Install MongoDB

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 folder called db inside the data folder you just created in previous step.
install mongodb config step1
Install MongoDB

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 config step2
Install MongoDB
  • Click New and paste the copied environment system link into Edit Environment Variable and click Ok.
install mongodb config step4
Install MongoDB
  • 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})
You should check all the steps above and follow them step-by-step to ensure there are no typographical errors and you haven’t missed anything if you see something that looks like bash mongo command not found.
We value your feedback.
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!
icon

Leave a Reply

Your email address will not be published. Required fields are marked *