I have a rails app deployed elsewhere that accesses a Mongo DB running on my local box (at my home). The remote box ip address is the only external address allowed to access the DB. Two nights ago I had a power outage. My box is connected to a UPS with a good battery and the house is on a whole-house generator. I mention that only because it seemed to me that the power hit might have caused the problem I experienced. To whit: the next morning my database was empty. All documents were gone. After recovering, two days later the same thing happened. This time it didn't happen overnight. I can tell that it happened sometime between 11:00am and 3:00pm. I'm not sure this is a question for DB Admin, maybe more of a security question, but is there any way that I can get Mongo to help me discover how this is happening?


Go thru mongodb.log, check that all incoming connections are from your own app address. That there was no other error what could make this happen. If you have OpLog in use, check what happen, was DROP command given.

My guess is that, you find out that "somebody" managed to connect your MongoDB and gave "drop database" command...

| improve this answer | |
  • If someone had done a drop database command, would I be able to 'use dbname' successfully? Probably just doing a use creates what doesn't exist. – rdiddly May 17 '19 at 11:42
  • Yes! Even you don't have any databases you can use "use db-of-some-name" command. The Easiest way to create new database is "use my-new-db; db.collection-name.insert({});" and you have new DB with collection and one document! – JJussi May 18 '19 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.