Friday, October 10, 2014

MongoDB in Windows- error system cannot find the file specified

When you start MongoDB from the command prompt (not from the bin folder), you may get this error saying "error system cannot find the specified". This doesn't give you enough information on what triggers this error. Go to the respective bin folder of MongoDB and start the MongoDB, you will get the below error. The default db path for mongodb is /data/db/, MongoDB checks if /data/db/ is present and if the user has access to it. In your case, there is no such directory and hence the error.

mongod.exe --help for help and startup options
2014-10-10T17:45:58.896+0530 [initandlisten] MongoDB starting : pid=10100 port=27017 dbpath=\data\db\ 64-bit host=EEI3054
2014-10-10T17:45:58.897+0530 [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2014-10-10T17:45:58.897+0530 [initandlisten] db version v2.6.5
2014-10-10T17:45:58.897+0530 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6
2014-10-10T17:45:58.897+0530 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2
Pack 1') BOOST_LIB_VERSION=1_49
2014-10-10T17:45:58.898+0530 [initandlisten] allocator: system
2014-10-10T17:45:58.898+0530 [initandlisten] options: {}
2014-10-10T17:45:58.903+0530 [initandlisten] exception in initAndListen: 10296
*********************************************************************
ERROR: dbpath (\data\db\) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating


However you can override the default db path using the --dbpath argument of mongod. Try running the below command. I have provided dbpath of my configuration, you can change it where you want to have it.

mongod.exe --dbpath "c://data/db"

In this case instead of checking for /data/db/ mongoDB check for c://data/db. In your case, you have the specified directory and you have access to it and hence it runs.

Happy Programming...!!!

No comments:

Post a Comment