Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to remove existing content before entering a replicaset the first time?

mongodb worries about:

... has data already, cannot initiate set. All members except initiator must be empty.

share|improve this question

db.dropDatabase() will drop the database, which will also drop all of the collections within a database.

If you need to see what databases you have, you can do show dbs.

Update: Here's a script to delete everything, make sure you really want to do this:

var dbs = db.getSisterDB('admin').adminCommand("listDatabases").databases
for(d in dbs) db.getSisterDB(dbs[d].name).dropDatabase();
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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