Reputation: 1327
I tried to run a mongoDB with corrupted files, now it won't load, won't start. how do I get rid of this corrupted files now? can I just delete the contents of 'var/lib/mongodb'?
Upvotes: 0
Views: 706
Reputation: 9665
Yes, if you don't need any of your data, just delete the files there. It will remove all the data, indexes and metadata.
If you are running in a replica set, you can do this too and it will automatically download all the data from one of the other healthy nodes which is really cool!
Upvotes: 1
Reputation: 817
var dbs = db.getMongo().getDBNames()
for(var i in dbs){
db = db.getMongo().getDB( dbs[i] );
print( "dropping db " + db.getName() );
db.dropDatabase();
}
save it to dropall.js and then execute:
mongo dropall.js
Upvotes: 0