How do I create a MongoDB dump of my database?

前端 未结 19 2478
既然无缘
既然无缘 2020-12-22 15:06

What command do I use and run?

19条回答
  •  死守一世寂寞
    2020-12-22 15:57

    You need to open command prompt as an administrator in a folder where your Mongo is installed (in my case: C:\Program Files\MongoDB\Server\3.4\bin). If you want to dump your whole database, you can just use:

    mongodump --db database_name
    

    You also have posibilities to dump only certain collection(s), or to dump all but certain collection(s).

    If you want to dump only one collection (for example users):

    mongodump  --db database_name --collection users
    

    If you want to dump all but users collection:

    mongodump  --db database_name --excludeCollection=users
    

    It is also possible to output the dump to an archive file:

    mongodump --archive=test.archive --db database_name
    

提交回复
热议问题