📅  最后修改于: 2022-03-11 14:51:40.952000             🧑  作者: Mango
Before MongoDB version 4.2
source_db.copyDatabase('destination_db')
After MongoDB version 4.2
mongodump --archive="mongodump-source-db" --db=source_db
mongorestore --archive="mongodump-source-db" --nsFrom='source_db.*' --nsTo='destination_db.*'
Or,
mongodump --archive --db=source_db | mongorestore --archive --nsFrom='source_db.*' --nsTo='destination_db.*'