- Reference >
- JavaScript Methods >
- db.repairDatabase()
db.repairDatabase()¶
-
db.repairDatabase()¶ Warning
In general, if you have an intact copy of your data, such as would exist on a very recent backup or an intact member of a replica set, do not use
repairDatabaseor related options likedb.repairDatabase()in themongoshell ormongod --repair. Restore from an intact copy of your data.Note
When using journaling, there is almost never any need to run
repairDatabase. In the event of an unclean shutdown, the server will be able restore the data files to a pristine state automatically.db.repairDatabase()provides a wrapper around the database commandrepairDatabase, and has the same effect as the run-time optionmongod --repairoption, limited to only the current database. SeerepairDatabasefor full documentation.