不幸的是,我无法将单个集合还原到现有的数据库中。我使用MongoVersion2.6.7运行Ubuntu14.04,在我的主目录下有一个dump/mydbname/contents.bson。
如果我跑了
mongorestore --collection contents --db mydbname然后我得到:
connected to: 127.0.0.1
don't know what to do with file [dump]如果我把路径加进去
mongorestore --collection contents --db mydbname --dbpath dump/mydbname然后我得到
If you are running a mongod on the same path you should connect to that instead of direct data file access我尝试过各种其他的组合,选项等,只是不明白,所以我来社区寻求帮助!
发布于 2015-02-21 00:39:40
如果要还原单个集合,则必须指定集合的转储文件。集合的转储文件位于' dump /dbname/‘文件夹中。因此,假设转储文件夹位于当前的工作目录中,则该命令将执行类似于-
mongorestore --db mydbname --collection mycollection dump/mydbname/mycollection.bson发布于 2019-09-04 18:37:31
我认为现在--nsInclude选项已经完成了:
mongorestore --nsInclude test.purchaseorders dump/
dump/是包含单根数据的文件夹,test是db,purchaseorders是集合。
https://docs.mongodb.com/manual/reference/program/mongorestore/
发布于 2018-11-29 15:07:48
恢复mongodb中特定集合的步骤。
1)转到存在转储文件夹的目录。
2)根据db名称和集合名称进行修改,执行以下命令。
mongorestore --db mydbname --collection mycollection dump/mydbname/mycollection.bson如果获得Failed: yourdbname.collection.name: error creating indexes for collection.name: createIndex error: The field 'safe' is not valid for an index specification error**,,则可以使用以下命令:**
mongorestore --db mydbname --collection mycollection dump/mydbname/mycollection.bson --noIndexRestorehttps://stackoverflow.com/questions/28640281
复制相似问题