Categories: MongoDB

How to install MongoDB on Windows

<div dir&equals;"ltr" style&equals;"text-align&colon; left&semi;">In this tutorial&comma; we will show you how to install <b><i>MongoDB <&sol;i><&sol;b>on Windows&period; There are following steps to Install <b><i>MongoDB <&sol;i><&sol;b>on windows OS&period;<&sol;p>&NewLine;<h2><b>Step&colon; 1&period; Download MongoDB-<&sol;b><&sol;h2>&NewLine;<p>Download the MongoDB from the official <a href&equals;"http&colon;&sol;&sol;www&period;mongodb&period;org&sol;downloads" target&equals;"&lowbar;blank" rel&equals;"noopener">MongoDB website<&sol;a>&period; Pre built binary packages of MongoDb are available for both 32 bit and 64 bit&period; You can download it&comma; and install&period;<&sol;p>&NewLine;<h2><b>Step&colon; 2&period; Unzip MongoDB folder <i>and creating directory<&sol;i>&&num;8211&semi; <&sol;b><&sol;h2>&NewLine;<p>Unzip it to your prefer location&comma; for example &colon; <b>C&colon;mongodb<&sol;b><&sol;p>&NewLine;<h2><b>Step&colon; 3&period; Review MongoDB folder-<&sol;b><&sol;h2>&NewLine;<p>In MongoDB v2&period;2&period;2&comma; it contains only 13 executable files &lpar;exe&rpar; in the bin folder&period;<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;01&sol;mongodb&period;png" border&equals;"0" &sol;><&sol;div>&NewLine;<h2><b>Step&colon; 4&period; Set Up The Environment<&sol;b><&sol;h2>&NewLine;<p>MongoDB requires a <a class&equals;"reference internal" href&equals;"http&colon;&sol;&sol;docs&period;mongodb&period;org&sol;manual&sol;reference&sol;glossary&sol;&num;term-dbpath" target&equals;"&lowbar;blank" rel&equals;"noopener"><em class&equals;"xref std std-term">data folder<&sol;em><&sol;a> to store its files&period; The default location for the MongoDB data directory is C&colon;datadb&period; Create this folder using the <em class&equals;"guilabel">Command Prompt<&sol;em>&period; Issue the following command sequence&colon;<&sol;p>&NewLine;<div class&equals;"highlight-powershell">&NewLine;<div class&equals;"highlight">&NewLine;<pre>md data &NewLine;md datadb &NewLine;<&sol;pre>&NewLine;<&sol;div>&NewLine;<&sol;div>&NewLine;<div class&equals;"admonition note">&NewLine;<div class&equals;"first admonition-title">Note<&sol;div>&NewLine;<p>You may specify an alternate path for datadb with the <a class&equals;"reference internal" title&equals;"dbpath" href&equals;"http&colon;&sol;&sol;docs&period;mongodb&period;org&sol;manual&sol;reference&sol;configuration-options&sol;&num;dbpath" target&equals;"&lowbar;blank" rel&equals;"noopener">dbpath<&sol;a> setting for <a class&equals;"reference internal" title&equals;"mongod&period;exe" href&equals;"http&colon;&sol;&sol;docs&period;mongodb&period;org&sol;manual&sol;reference&sol;mongod&period;exe&sol;&num;mongod&period;exe" target&equals;"&lowbar;blank" rel&equals;"noopener">mongod&period;exe<&sol;a>&comma; as in the following example&colon;<&sol;p>&NewLine;<div class&equals;"highlight-powershell">&NewLine;<pre class&equals;"highlight">C&colon;mongodbbinmongod&period;exe --dbpath d&colon;testmongodbdata<&sol;pre>&NewLine;<&sol;div>&NewLine;<p>If your path includes spaces&comma; enclose the entire path in double quotations&comma; for example&colon;<&sol;p>&NewLine;<div class&equals;"last highlight-powershell">&NewLine;<pre class&equals;"highlight">C&colon;mongodbbinmongod&period;exe --dbpath "d&colon;testmongo db data"<&sol;pre>&NewLine;<&sol;div>&NewLine;<&sol;div>&NewLine;<h2><b>Step&colon; 5&period; Run the MongoDb server from command prompt<&sol;b><&sol;h2>&NewLine;<p>To run MongoDb server from command prompt&comma; you have to execute mongod&period;exe file from bin folder of mongodb folder&period;<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;01&sol;mongodbcmd-1&period;png" width&equals;"600" height&equals;"328" border&equals;"0" &sol;><&sol;div>&NewLine;<h2><b>Step&colon; 6&period; In additional&comma; MongoDB come with a web admin interface listening on port 28017&period;<&sol;b><&sol;h2>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;01&sol;mongodbtutorials-1024x576&period;png" width&equals;"600" height&equals;"359" border&equals;"0" &sol;><&sol;div>&NewLine;<h2><b>Step&colon; 7&period; Connect to MongoDB<&sol;b><&sol;h2>&NewLine;<h2>&NewLine;<img class&equals;"aligncenter" src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2013&sol;01&sol;mongo-1&period;png" border&equals;"0" &sol;><&sol;h2>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<div style&equals;"background-color&colon; &num;ff99cc&semi;">                        <b>     &lt&semi;&lt&semi;<a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;introduction-to-mongodb&sol;">previous<&sol;a>&lt&semi;&lt&semi;             &vert;&vert; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;introduction-to-mongodb&sol;">index  <&sol;a>&vert;&vert;         &gt&semi;&gt&semi;<a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;mongodb-hello-world-example&sol;">next<&sol;a>&gt&semi;&gt&semi;<&sol;b><&sol;div>&NewLine;<&sol;div>&NewLine;<div class&equals;"wp-post-navigation"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-pre"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;introduction-to-mongodb&sol;">Previous<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-next"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;mongodb-hello-world-example&sol;">Next<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;<script type&equals;"text&sol;javascript">&NewLine;jQuery&lpar;document&rpar;&period;ready&lpar;function&lpar;&dollar;&rpar; &lbrace;&NewLine; &dollar;&period;post&lpar;'https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-admin&sol;admin-ajax&period;php'&comma; &lbrace;action&colon; 'mts&lowbar;view&lowbar;count'&comma; id&colon; '596'&rcub;&rpar;&semi;&NewLine;&rcub;&rpar;&semi;&NewLine;<&sol;script>

Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design Patterns using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

4 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

4 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

4 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

4 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

4 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

4 years ago