0

I'm trying to connect to my db remotely, and having some trouble. A popular answer seems to be running

sudo rm /var/lib/mongodb/mongod.lock
sudo service mongodb restart

What are the consequences of running each of these commands? I am especially wondering:

  • Am I introducing potential problems by deleting the lock? Surely the lock must be there for a useful reason?
  • Will my data stay the same after the restart?
Community
  • 1
  • 1
Hatshepsut
  • 5,962
  • 8
  • 44
  • 80

1 Answers1

0

If mongodb is not running yet the lock file still exists, then your mongod service did not shut down gracefully (crashed). In this case, you can safely delete the lock file and your data will remain.

kliew
  • 3,073
  • 1
  • 14
  • 25
  • Sorry, I'm having trouble understanding your answer. Is it possible to clarify? – Hatshepsut Feb 10 '16 at 09:26
  • When you start mongod, it creates a lock file. When it shuts down gracefully, it clears the lock file. If the lock file still exists, then the process did not shut down gracefully. The purpose of the lock file is to keep one set of db files per mongod process while allowing multiple mongods to have their own db files. There are no side effects to removing the lock file if the mongod process is not running – kliew Feb 11 '16 at 02:59