MongoDB: Installing on Windows 7

It’s not my personal choice, but I have to spend a lot of my time working under Windows. Installing MongoDB under Ubuntu is a snap. Getting it going under Windows seems to require jumping through a few more hoops. Here are my notes. I hope that somebody will find them useful.

  1. Download the installation. This will be an MSI installer package with a name like mongodb-win32-x86_64-2008plus-ssl-3.2.0-signed.msi.
  2. Run the installer with a deft double-click.
Installation dialog for MongoDB.
  1. Accept the License Agreement.
  2. Select the Complete installation type and click Install.
  3. Briefly browse YouTube (you won’t have time to make a cup of coffee).
  4. When the installation is complete press Finish.
  5. Reboot your machine. This might not be entirely necessary, but my Windows experience tells me that it is never a bad idea.
  6. Create a folder for the data files. By default this will be C:\data\db.
  7. Create a folder for the log files. By default this will be C:\data\log.
  8. Open a command prompt, change the working directory to C:\Program Files\MongoDB\Server\3.2\bin and start the database server, mongod.exe.
Starting the MongoDB server from the command line.

At this stage you should be ready to roll. Open another command prompt and start the database client, mongo.exe which you’ll find in the same folder as mongod.exe.

To make your installation a little more robust, you can also do the following:

  1. Create a configuration file at C:\Program Files\MongoDB\Server\3.2\mongod.cfg. For starters you could enter the following configuration directives:
    systemLog:
        destination: file
        path: c:\data\log\mongod.log
    storage:
        dbPath: c:\data\db
    
  2. Install MongoDB as a service by running
    mongod.exe -config "C:\Program Files\MongoDB\Server\3.2\mongod.cfg" -install
    
  3. The service can then be launched with
    net start MongoDB
    
    And stopping the service is as simple as
    net stop MongoDB