[英]How to open mongo-db dump file?
I have a .dump file (8GB) which is a mongo database that I need to work with.我有一个 .dump 文件 (8GB),它是我需要使用的 mongo 数据库。 I'm working with Robo 3T.我正在使用 Robo 3T。
I've tried:我试过了:
mongorestore --db cert-db certctream.dump
command, got error (using certctream without the extension didn't work as well) b) mongorestore --db cert-db certctream.dump
命令,出现错误(使用没有扩展名的 certctream 效果不佳)Failed: file certctream.dump does not have .bson extension失败:文件 certctream.dump 没有 .bson 扩展名
What am I missing?我错过了什么?
解决方案:
mongoimport --db <new_db_name> --host localhost:27017 path_to_dump_file
To import a mongo collection:要导入 mongo 集合:
mongoimport -d database_name -c collection_name
In this case, collection_name
would be the JSON file for the corresponding collection.在这种情况下, collection_name
将是相应集合的 JSON 文件。
To import a mongo database:导入 mongo 数据库:
mongorestore -d database_name
In this case, database_name
would be a folder.在这种情况下, database_name
将是一个文件夹。
To restore from a .dump
file you need to use the archive
argument:要从.dump
文件恢复,您需要使用archive
参数:
mongorestore --archive=mydump.dump
GOTCHA GOTCHA
The dump may have also been gzipped, in which case you'll get:转储也可能已被 gzip 压缩,在这种情况下,您将获得:
Failed: stream or file does not appear to be a mongodump archive
In this case, try adding --gzip
as it might do the job:在这种情况下,尝试添加--gzip
因为它可能会完成这项工作:
mongorestore --gzip --archive=mydump.dump
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.