To install MongoDB on your Windows 10 machine, follow the following steps.
- Go to MongoDB website and download the Community version of the package like you see in the image below:
- Once the download finishes, double click on the .msi file to start the installation. Install using the default settings, installing Complete package.
- Once installation completes, we need to add MongoDB to the Path in System Variables so that you can use the MongoDB commands in the command prompt. Right click on the Windows icon (the very left icon) on the taskbar and click on ‘System’.
- Click on Advanced System Settings on the left hand side and then when the window pops up, click on the Advanced tab and find Environment Variables…
- Under the System Variables, double click on Path to add a new path for MongoDB:
You can also click on ‘New…’ button to add a new variable.
- Once the new window opens, add a new path for MongoDB according to your download path. If you used the default install settings, your install path for MongoDB should be similar to this:
3.2 is the version number, so just double check what your version number is before adding it in. Then click OK to save the changes.
- Then open your command prompt and type:
$ mkdir C:\data\db\
This is where all your database collection information is stored. NOT where your actual database for your app is stored.
- Now to connect your path to this directory, type this in the command prompt:
$ mongod --dbpath <path where you want your database for your app stored>
$ mongod --dbpath C:\Users\Ellen\myfirstapp\contacts
- To check if your MongoDB is set up correctly, you can always run
You’ll get a response like the following: