MongoDb:如何从.gz文件导入转储数据? [英] MongoDb: How to import dump data from .gz file?

查看:1508
本文介绍了MongoDb:如何从.gz文件导入转储数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的.gz文件导入转储数据.

I want to import dump data from my .gz file.

文件位置为home/Alex/Documents/Abc/dump.gz,数据库名称为"Alex".

Location of file is home/Alex/Documents/Abc/dump.gz and the name of db is "Alex".

我尝试了mongorestore --gzip --db "Alex" /home/Alex/Documents/Abc/dump.gz

但显示错误:

 2018-10-31T12:54:58.359+0530   the --db and --collection args should 
 only be used when restoring from a BSON file. Other uses are 
 deprecated and will not exist in the future; use --nsInclude instead
 2018-10-31T12:54:58.359+0530   Failed: file 
 /home/Alex/Documents/Abc/dump.gz does not have .bson extension.

如何导入?

推荐答案

转储命令:

mongodump --host localhost:27017 --gzip --db Alex --out ./testSO

还原命令:

mongorestore --host localhost:27017 --gzip --db Alex ./testSO/Alex

完美工作!

转储命令:

mongodump --host localhost:27017 --archive=dump.gz --gzip --db Alex

还原命令:

mongorestore --host localhost:27017 --gzip --archive=dump.gz --db Alex


注意:-:在使用存档时,您需要坚持使用database name.

Note:- While using archive you need to stick with the database name.

不支持不同的数据库名称或集合名称.有关更多信息.

Different database name or collection name is not supported. For more info.

这篇关于MongoDb:如何从.gz文件导入转储数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆