首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mongodb将数据转储到另一个目录

mongodb将数据转储到另一个目录
EN

Stack Overflow用户
提问于 2012-09-05 07:34:25
回答 1查看 1.4K关注 0票数 0

我知道我可以用这个常识来转储数据

代码语言:javascript
复制
mongodump --db mydb

此命令将所有mydb集合数据转储到./ dump /mydb。但是我想将数据转储到我命名的另一个目录(比如/home/user/mydb)

我尝试过使用--dbpath和--directoryperdb选项,但这似乎不是我想要的

有没有办法做到这一点?

./mongodump --帮助

将MongoDB数据导出到BSON文件。

选项:

代码语言:javascript
复制
 --help                   produce help message
  -v [ --verbose ]         be more verbose (include multiple times for more
                           verbosity e.g. -vvvvv)
  --version                print the program's version and exit
  -h [ --host ] arg        mongo host to connect to ( <set name>/s1,s2 for
                           sets)
  --port arg               server port. Can also use --host hostname:port
  --ipv6                   enable IPv6 support (disabled by default)
  -u [ --username ] arg    username
  -p [ --password ] arg    password
  --dbpath arg             directly access mongod database files in the given
                           path, instead of connecting to a mongod  server -
                           needs to lock the data directory, so cannot be used
                           if a mongod is currently accessing the same path
  --directoryperdb         if dbpath specified, each db is in a separate
                           directory
  --journal                enable journaling
  -d [ --db ] arg          database to use
  -c [ --collection ] arg  collection to use (some commands)
  -o [ --out ] arg (=dump) output directory or "-" for stdout
  -q [ --query ] arg       json query
  --oplog                  Use oplog for point-in-time snapshotting
  --repair                 try to recover a crashed database
  --forceTableScan         force a table scan (do not use $snapshot) 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-05 07:53:56

您需要-o选项:

代码语言:javascript
复制
  -o [ --out ] arg (=dump) output directory or "-" for stdout

这将允许您指定输出的位置。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12272677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档