Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to repair my mongodb?

Tags:

mongodb

I can't seem to connect to Mongo DB, which I've installed as a Windows Service on my local machine. I've also built a little WPF application which communicates with MongoDB. The errormessage:

Error: couldn't connect to server 127.0.0.1 shell/mongo.js:8 4 exception: connect failed Unclean shutdown detected.

like image 817
marko Avatar asked Mar 31 '12 05:03

marko


People also ask

How do I restore my MongoDB database?

Restoring MongoDB From a Backup There are basically two ways you can use a BSON format dump: Run mongod directly from the backup directory. Run mongorestore and restore the backup.

What does mongod command do?

The main purpose of mongod is to manage all the MongoDB server tasks. For instance, accepting requests, responding to client, and memory management. mongo is a command line shell that can interact with the client (for example, system administrators and developers).


2 Answers

You should launch it with --repair flag.

mongod --repair 

After repair is finished, stop this one and launch it normally. Documentation on --repair option.

like image 61
Sergio Tulentsev Avatar answered Sep 20 '22 18:09

Sergio Tulentsev


Quicker:

sudo rm /data/db/mongod.lock sudo mongod --dbpath /data/db --repair sudo mongod --dbpath /data/db 
like image 25
Moin Haidar Avatar answered Sep 20 '22 18:09

Moin Haidar