Skip to main content

How do you rename a MongoDB database



Even I did not find any command to rename database directly.


To rename database please track  following steps.

1- Copy your old database to new renamed database.

    db.copyDatabase("db_old","db_new_renamed","localhost")

2- Select old database using USE key.

    use db_old

3-  Drop Old Database

     db.dropDatabase();