来自DOS或Windows的MongoDB命令 [英] MongoDB commands from DOS or Windows

查看:154
本文介绍了来自DOS或Windows的MongoDB命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从C#程序自动将4个集合从一个Mongo数据库复制到同一台计算机上的另一个数据库.我怎么做? MongoDB C#驱动程序中是否有一个简单的副本收集/数据库命令?还是我必须先输入./mongo来使用Mongo shell?如果是这样,我该如何在MS-DOS命令行窗口中执行此操作?像./mongo -copycollection from to一样?

I'm trying to copy 4 collections from one Mongo database to another on the same machine from C# program automatically. How do I do that? Is there a simple copy collection/database command in MongoDB C# driver? or do I have to use the Mongo shell by first typing the ./mongo? If so how do I do that inside a MS-DOS command line window? Like ./mongo -copycollection from to?

推荐答案

使用mongodump,类型:

Use mongodump, Type:

./mongodump --db your_db_name --collection collection_name  

然后mongorestore:

and then mongorestore:

./mongorestore --db=new_db_name

了解更多: mongodump 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆