How to connect to MongoDB in Windows?

Did you create the default db path?
It defaults to "/data/db directory (or c:\data\db on Windows)"
Source: http://www.mongodb.org/display/DOCS/Starting+and+Stopping+Mongo


I found that when I got this error it wasn't because I didn't have my default db path set up. It was because I was trying to run mongo.exe before running mongod.exe.


  1. As Admin, create directory:

    mkdir c:\mongo\data\db
    
  2. As Admin, install service:

    .\mongod.exe --install --logpath c:\mongo\logs --logappend --bind_ip 127.0.0.1 --dbpath c:\mongo\data\db --directoryperdb
    
  3. Start MongoDB:

    net start MongoDB
    
  4. Start Mongo Shell:

    c:\mongo\bin\mongo.exe