title: Drop all indexes from all collections in a MongoDB database using the command line
body: <p>I've used mongorestore to restore a database but I'm getting an error that the index already exists when I try to run my application.</p>
  
  <p>I know of the function db.collection.dropIndex() but is there a way to automate this and drop all indexes from all collections in a database at once?</p>
  
  <p>I've tried</p>
  
  <pre><code>db.getCollectionNames().forEach(function(col_name) {   
     var coll = db.getCollection(col_name);   
     coll.dropIndexes(); 
  });
  </code></pre>
  
  <p>But that doesn't do the trick.
  Any ideas?</p>