Create a file called mongod.cfg in MongoDB folder if you dont have it. In my case: C:UsersivanbtrujilloMongoDB
Then, edit mongod.cfg with notepad and add a line with the following (our custom dbpath):
dbpath=C:UsersivanbtrujilloMongoDBdatadb
In this file you should especify the logpath too. My mongod.cfg file is:
logpath=C:UsersivanbtrujilloMongoDBlogmongo.log
dbpath=C:UsersivanbtrujilloMongoDBdatadb
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:UsersivanbtrujilloMongoDBinmongod.exe" --config "C:UsersivanbtrujilloMongoDBmongod.cfg" –install**
Open regedit.exe and go to the following route:
HKEYLOCALMACHINESYSTEMCurrentControlSetservicesMongoDB
MongoDB service does not work, we have to edit the ImagePath key, delete its content and put the following:
**"C:UsersivanbtrujilloMongoDBinmongod.exe" --config "C:UsersivanbtrujilloMongoDBmongod.cfg"
--logpath="C:UsersivanbtrujilloMongoDBlogmongo.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/