How to rename a mongodb collection

09th Sep, 2013 | mongodb

On installing a sample node.js application the associated mongo files ended up with long collection names including '.' and digit blocks.

To rename you cannot access the collection directly, as the dot-digit combination is illegal. Instead use

db.getCollection('mongodump.20130805.Customer').renameCollection('Customer');

to solve the problem.