如何将mongodump用于1个集合 [英] How to use mongodump for 1 collection
本文介绍了如何将mongodump用于1个集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用mongodump
将单个集合从一个数据库移动到另一个数据库?
How can I use mongodump
to move a single collection from one database to another?
我应该如何使用该命令及其选项?
How should I use the command and its options?
推荐答案
我认为这只是:
mongodump --db=<old_db_name> --collection=<collection_name> --out=data/
mongorestore --db=<new_db_name> --collection=<collection_name> data/<db_name>/<collection_name>.bson
顺便说一句,将集合从一个数据库移动到另一个数据库的另一种方法是使用renameCollection
:
Btw, the other way to move the collection from one database to another is to use renameCollection
:
db.runCommand({renameCollection:"<old_db_name>.<collection_name>",to:"<new_db_name>.<collection_name>"})
以下是一些相关的SO线程:
Here's some related SO threads:
- How to copy a collection from one database to another in MongoDB
- How to use the dumped data by mongodump?
希望有帮助.
这篇关于如何将mongodump用于1个集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文