Create a file called mongod.cfg in MongoDB folder if you dont have it. In my case: C:\Users\ivanbtrujillo\MongoDB
Then, edit mongod.cfg with notepad and add a line with the following (our custom dbpath):
dbpath=C:\Users\ivanbtrujillo\MongoDB\data\db
In this file you should especify the logpath too. My mongod.cfg file is:
logpath=C:\Users\ivanbtrujillo\MongoDB\log\mongo.log dbpath=C:\Users\ivanbtrujillo\MongoDB\data\db
If you uses mongoDB as a windows service, you have to change this key and especify the mongod.cfg file.
To install mongodb as a windows service run this command:
**"C:\Users\ivanbtrujillo\MongoDB\bin\mongod.exe" --config "C:\Users\ivanbtrujillo\MongoDB\mongod.cfg" –install**
Open regedit.exe and go to the following route:
HKEYLOCALMACHINE\SYSTEM\CurrentControlSet\services\MongoDB
MongoDB service does not work, we have to edit the ImagePath key, delete its content and put the following:
**"C:\Users\ivanbtrujillo\MongoDB\bin\mongod.exe" --config "C:\Users\ivanbtrujillo\MongoDB\mongod.cfg"
--logpath="C:\Users\ivanbtrujillo\MongoDB\log\mongo.log" –service**
We indicates to mongo it's config file and its logpath.
Then when you init the mongodb service, it works.
Here is a full tutorial to install mongoDB in windows:http://ivanbtrujillo.herokuapp.com/2014/07/24/installing-mongodb-as-a-service-windows/