If you've been exploring the MEAN Stack (MongoDB, ExpressJS, AngularJS and Node.....for those not in the know!) you may have encountered the following problem when attempting to start MongoDB from the command line:
old lock file: /data/db/mongod.lock. probably means unclean shutdown, but there are no journal files to recover. this is likely human error or filesystem corruption. please make sure that your journal directory is mounted.
Resolving this issue is relatively straightforward...
Within the same terminal window navigate to where MongoDB stores its database (by default this is normally in the following location: /data/db) and issue the following instruction:
What we are doing here is completely removing the current mongo.d lock file so as to begin the process of repairing our database.
This file is written at the start of the MongoDB server and subsequently dropped when the server is stopped. If the server should be shutdown incorrectly (such as closing the terminal window without properly exiting the mongod process) then this file can become corrupted resulting in the error message displayed at the beginning of this article.
The next terminal command instructs the Mongo daemon to repair the database, specifying the path to where the database is located:
mongod --dbpath /data/db --repair
And finally we instruct the Mongo daemon to start up using the --dbpath flag, specifying the location of the database:
mongod --dbpath /data/db
All things being well you should now see the MongoDB console running normally.