I have a .dump file (8GB) which is a mongo database that I need to work with. I'm working with Robo 3T.
I've tried:
mongorestore --db cert-db certctream.dump
command, got error (using certctream without the extension didn't work as well) Failed: file certctream.dump does not have .bson extension
What am I missing?
解决方案:
mongoimport --db <new_db_name> --host localhost:27017 path_to_dump_file
To import a mongo collection:
mongoimport -d database_name -c collection_name
In this case, collection_name
would be the JSON file for the corresponding collection.
To import a mongo database:
mongorestore -d database_name
In this case, database_name
would be a folder.
To restore from a .dump
file you need to use the archive
argument:
mongorestore --archive=mydump.dump
GOTCHA
The dump may have also been gzipped, in which case you'll get:
Failed: stream or file does not appear to be a mongodump archive
In this case, try adding --gzip
as it might do the job:
mongorestore --gzip --archive=mydump.dump
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.