Chapter 1: The Mongod Lab - Change the Default DB Path

Chapter 1: The Mongod

Lab - Change the Default DB Path

2019-08-26T01:42:08.618+0000 I STORAGE [initandlisten] exception in initAndListen: DBPathInUse: Unable to create/open the lock file: /var/mongodb/db/config.txt/mongod.lock (Not a directory). Ensure the user executing mongod is the owner of the lock file and has the appropriate permissions. Also make sure that another mongod instance is not already running on the /var/mongodb/db/config.txt directory, terminating

I ahve chowned /var/mongod/db to vagrant:vagrant.
There is no mongod instance running

Hey @bferro

Did you at some point run the mongod process as root? If so this would have created a mongod.lock file in the directory. If you then try to launch using a different user you will see the error above.

Try this

ls -a /var/mongod/db
# is there a mongod.lock file?
# if so who owns it?

You can delete the .lock file and try to launch your mongod process again.

Did you use the recursive flag for this command?

sudo chown -R vagrant:vagrant /var/mongod
1 Like