Installing MongoDB on Windows 10


You can download the installer file (.msi) from the Mongo website. It is free when you choose Community Server. You can download MongoDB for four different operating systems: Windows, Linus, OSX and Solaris. Choose the appropriate tab for your OS. For Windows, you will want to choose the default: Windows Server 2008 R2 64-bit and later, with SSL support x64. This includes Windows 10 because it is for Windows Server 2008 R2 64-bit and later. For an introduction to MongoDB please see our other post MongoDB Introduction.

Download it, save it to your hard drive and run it. When you run the installer you will go through the following steps.

  • Welcome screen
  • End user license agreement
  • Install Complete. If you wish you can install the Custom.
  • Install
  • Windows asks if you trust it. Click Yes.
  • Open Windows Explorer
  • Navigate to c:\Program Files\MongoDB\Server\bin and just take note of mongo and mongod
  • On your hard drive make a new directory c:\data\db
  • Open a command line by runnoing cmd

mongoport27017

Mongod is the database that runs in the background. It is waiting for connections on port 27017. That’s fine. It is working. In order to get to the mongo command line you run another command prompt and type mongo. But before you do that, follow the instructions to create an environment variable to make life easier for you.

Make an Environment Variable

There is an easier way to run momgo than typing the full path in the command line. We can create an environment variable. Go to the Control Panel, System and Security, Advanced System Settings, Environment Variables, New. Now you give it a name of PATH. Put PATH all in capitals. Type the path to the bin directory in the variable value. it is C:\Program Files\MongoDB\Server\3.2\bin. Click OK three times.

Create a new command prompt by running cmd. Type mongo.

mongocommandline

MEAN Stack

MongoDB is part of the MEAN stack, which includes MongoDB, Express, Angular.js and Node.js.