Installing MongoDB on Windows
What’s MongoDB?
MongoDB is a document database which belongs to a family of databases called NoSQL - not only SQL. In MongoDB, records are documents which behave a lot like JSON objects in JavaScript. Values in documents can be looked up by their field’s key. Documents can have some fields/keys and not others, which makes Mongo extremely flexible.
This is different than SQL databases like MySQL and PostgreSQL, where fields correspond to columns in a table and individual records correspond to rows.
Prerequisites
You should have a general familiarity with the Windows command prompt.
Installing and Running MongoDB on a Windows Machine
-
Download the MongoDB installer file from the downloads section of the MongoDB website.
-
Find the dowloaded .msi file in the Windows Explorer. Double click the file and follow the prompts to install Mongo. Note: unless you specify a custom directory Mongo is most likely installed in the
C:\mongodb
directory**. However, based on settings on your machine Mongo may be installed other places. For example,C:\Program Files\MongoDB\Server\3.2
. Additionally, you may find MongoDB in the add/remove programs menu. -
Create the directory where MongoDB will store it’s files. From the command prompt run
md \data\db
. This is the default location. However, other locations can be specified using the--dbpath
parameter. See the Mongo docs for more information. -
Start the mongodb daemon by running
C:\mongodb\bin\mongod.exe
in the Command Prompt. Or by running,C:\path\to\mongodb\bin\mongod.exe
-
Connect to MongoDB using the Mongo shell While the MongoDB daemon is running, from a different Command prompt window run
C:\mongodb\bin\mongo.exe