This was only tested on Windows 7.

  1. Download and install from MongoDB website
  2. Select appropriate MSI or ZIP either for 32 or 64 bit system
  3. Once installed, locate the installation directory usually on C:\Program Files (x86)\MongoDB
  4. Create 2 folders and a file namely:
    1. log
    2. data
    3. mongo.config
  5. Next, Open the mongo.config file and type these 3 lines:
    • dbpath=C:\Program Files (x86)\MongoDB\data
    • logpath=C:\Program Files (x86)\MongoDB\log\mongo.log
    • diaglog=3
  6. Open command prompt as Administrator
  7. Go to the bin folder inside the installation directory cd C:\Program Files (x86)\MongoDB\Server\3.0\bin
  8. Type mongod.exe ––config=”C:\Program Files (x86)\MongoDB\mongo.config”
  9. Open another command prompt as Administrator , go again to the bin directory and type mongo
  10. In the Mongo Shell, type db. It should display a word test

* It’s up to you to put the paths in your environment variables

Other Items:

  • MongoDB can also be run by going to a NodeJS app’s bin directory using mongod.exe –dbpath path\to\my\nodejs\app\bin. Open another command prompt and type mongo
  • There are 2 default ports:
    • 27017
    • 28017 is used for accessing through the browser like http://localhost:28017 when starting mongo server using mongod.exe ––config=”C:\Program Files (x86)\MongoDB\mongo.config” ––rest
  • There’s no rename method for DBs. Use these instead:
    1. db.copyDatabase(‘fromDbName’, ‘toDbName’, ‘localhost’) to duplicate existing database
    2. use fromDbName switch to the the existing database to be deleted
    3. db.dropDatabase() to delete the used database
    4. use toDbName to switch to the newly created database
  • To dump a database along with its collections, there is only export to BSON option. The JSON option is per collection only. So use BSON instead: C:\Program Files (x86)\MongoDB\Server\3.0\bin>mongodump /d mynodejsapp /o mynodejsapp.json. The output will be contained in a mynodejsapp folder inside C:\Program Files (x86)\MongoDB\Server\3.0\bin