如题,在命令行里运行修改已有数据库名称
走同样的路,发现不同的人生
There is no direct method, only copy and then delete:
db.copyDatabase('old_name', 'new_name'); use old_name db.dropDatabase();
==2017.4.4 Update== is still an indirect solution, but WiredTigerthere is a more convenient solution for the storage engine: db.renameCollection.
WiredTiger
use admin; db.runCommand({renameCollection: "test.test", to: "test1.test"});
When you move all collections to a new library, it is equivalent to renaming the entire library. This will be much faster than copyDatabase.
copyDatabase
db.help()
There is no direct method, only copy and then delete:
==2017.4.4 Update==
is still an indirect solution, but
WiredTiger
there is a more convenient solution for the storage engine: db.renameCollection.When you move all collections to a new library, it is equivalent to renaming the entire library. This will be much faster than
copyDatabase
.Note: renameCollection cannot be used for shard sets
db.help()