Can't start mongodb service

Check mongodb logs. In my case mongodb could not find directory from mongod.cfg


In my case it appered to be mongod.lock issue after unexpected shutdown.

Detected unclean shutdown - E:\MongoDb\Databases\mongod.lock is not empty.

I deleted E:\MongoDb\Databases\mongod.lock and mongo successfuly started.


In Windows:

there is an effective method to solve this issue.

Firstly, try to delete the file storage.bson under the folder "D:\mongodb\data", or the corresponding path in your PC.

If the issue still exists, try following steps in order.

For example mongoDB version 3.6 is installed, and the install path of MongoDB is "D:\Program Files\MongoDB".

Create folder D:\mongodb\logs, then create file mongodb.log inside this folder.

Run cmd.exe as administrator,

D:\Program Files\MongoDB\Server\3.6\bin>taskkill /F /IM mongod.exe
D:\Program Files\MongoDB\Server\3.6\bin>mongod.exe --logpath D:\mongodb\logs\mongodb.log --logappend --dbpath D:\mongodb\data --directoryperdb --serviceName MongoDB --remove
D:\Program Files\MongoDB\Server\3.6\bin>mongod --logpath "D:\mongodb\logs\mongodb.log" --logappend --dbpath "D:\mongodb\data" --directoryperdb --serviceName "MongoDB" --serviceDisplayName "MongoDB" --install

Remove these two files mongod.lock and storage.bson under the folder "D:\mongodb\data".

Then type net start MongoDB in the cmd using administrator privilege, the issue will be solved.