我无法将单个集合恢复到现有数据库中,这很糟糕。 我正在使用 mongo 版本 2.6.7 运行 Ubuntu 14.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
我已经尝试了各种其他组合、选项等,但无法解开,所以我来社区寻求帮助!
最佳答案
如果要恢复单个集合,则必须指定集合的转储文件。集合的转储文件位于“dump/dbname/”文件夹中。因此,假设您的转储文件夹位于您当前的工作目录中,该命令将类似于 -
mongorestore --db mydbname --collection mycollection dump/mydbname/mycollection.bson
https://stackoverflow.com/questions/28640281/