mongoimport mongoexport

简介:

mongoexport:将数据导出成JSON格式,与标准的JSON有些不同

参数说明:

  1. [root@localhost mongodb]# ./bin/mongoexport --help  
  2. Export MongoDB data to CSV, TSV or JSON files.  
  3.   
  4. options:  
  5.   --help                    produce help message  
  6.   -v [ --verbose ]          be more verbose (include multiple times for more   
  7.                             verbosity e.g. -vvvvv)  
  8.   --version                 print the program's version and exit  
  9.   -h [ --host ] arg         mongo host to connect to ( <set name>/s1,s2 for   
  10.                             sets)  
  11.   --port arg                server port. Can also use --host hostname:port  
  12.   --ipv6                    enable IPv6 support (disabled by default)  
  13.   -u [ --username ] arg     username  
  14.   -p [ --password ] arg     password  
  15.   --dbpath arg              directly access mongod database files in the given   
  16.                             path, instead of connecting to a mongod  server -   
  17.                             needs to lock the data directory, so cannot be used  
  18.                             if a mongod is currently accessing the same path  
  19.   --directoryperdb          if dbpath specified, each db is in a separate   
  20.                             directory  
  21.   --journal                 enable journaling  
  22.   -d [ --db ] arg           database to use  
  23.   -c [ --collection ] arg   collection to use (some commands)  
  24.   -f [ --fields ] arg       comma separated list of field names e.g. -f   
  25.                             name,age  
  26.   --fieldFile arg           file with fields names - 1 per line  
  27.   -q [ --query ] arg        query filter, as a JSON string  
  28.   --csv                     export to csv instead of json  
  29.   -o [ --out ] arg          output file; if not specified, stdout is used  
  30.   --jsonArray               output to a json array rather than one object per   
  31.                             line  
  32.   -k [ --slaveOk ] arg (=1) use secondaries for export if available, default   
  33.                             true  


常用: mongoexport -d testdb -c testcol -o out.dat


mongoimport:从JSON导入,由于与标准的JSON略有些不同,如果出现错误,可以先导出看看mongo的格式要求,再导入

  1. [root@localhost mongodb]# ./bin/mongoimport --help  
  2. options:  
  3.   --help                  produce help message  
  4.   -v [ --verbose ]        be more verbose (include multiple times for more   
  5.                           verbosity e.g. -vvvvv)  
  6.   --version               print the program's version and exit  
  7.   -h [ --host ] arg       mongo host to connect to ( <set name>/s1,s2 for sets)  
  8.   --port arg              server port. Can also use --host hostname:port  
  9.   --ipv6                  enable IPv6 support (disabled by default)  
  10.   -u [ --username ] arg   username  
  11.   -p [ --password ] arg   password  
  12.   --dbpath arg            directly access mongod database files in the given   
  13.                           path, instead of connecting to a mongod  server -   
  14.                           needs to lock the data directory, so cannot be used   
  15.                           if a mongod is currently accessing the same path  
  16.   --directoryperdb        if dbpath specified, each db is in a separate   
  17.                           directory  
  18.   --journal               enable journaling  
  19.   -d [ --db ] arg         database to use  
  20.   -c [ --collection ] arg collection to use (some commands)  
  21.   -f [ --fields ] arg     comma separated list of field names e.g. -f name,age  
  22.   --fieldFile arg         file with fields names - 1 per line  
  23.   --ignoreBlanks          if given, empty fields in csv and tsv will be ignored  
  24.   --type arg              type of file to import.  default: json (json,csv,tsv)  
  25.   --file arg              file to import from; if not specified stdin is used  
  26.   --drop                  drop collection first   
  27.   --headerline            CSV,TSV only - use first line as headers  
  28.   --upsert                insert or update objects that already exist  
  29.   --upsertFields arg      comma-separated fields for the query part of the   
  30.                           upsert. You should make sure this is indexed  
  31.   --stopOnError           stop importing at first error rather than continuing  
  32.   --jsonArray             load a json array, not one item per line. Currently   
  33.                           limited to 4MB.  



目录
相关文章
|
SQL Cloud Native 关系型数据库
ADBPG(AnalyticDB for PostgreSQL)是阿里云提供的一种云原生的大数据分析型数据库
ADBPG(AnalyticDB for PostgreSQL)是阿里云提供的一种云原生的大数据分析型数据库
1161 1
|
JSON NoSQL 关系型数据库
MongoDB数据的导入与导出
MongoDB数据的导入与导出
633 0
|
4月前
|
JSON NoSQL MongoDB
mongodb通过mongoexport命令导出数据
mongodb通过mongoexport命令导出数据
|
4月前
|
监控 API 数据处理
Flink web ui不仅仅是一个监控指标性能的网站
Flink web ui不仅仅是一个监控指标性能的网站
236 3
|
10月前
|
JavaScript Linux 开发工具
Linux centos 安装nodejs完整教程 详细到不能再详细了
Linux centos 安装nodejs完整教程 详细到不能再详细了
327 0
|
JSON NoSQL Java
MongoDB:8-MongoDB的导入(mongoimport)和导出(mongoexport)
MongoDB:8-MongoDB的导入(mongoimport)和导出(mongoexport)
363 0
|
NoSQL MongoDB
MongoDB 常见问题 - 解决找不到 mongo、mongod 命令的问题
MongoDB 常见问题 - 解决找不到 mongo、mongod 命令的问题
1088 0
MongoDB 常见问题 - 解决找不到 mongo、mongod 命令的问题
|
消息中间件 SQL NoSQL
Flink CDC 系列 - Flink MongoDB CDC 在 XTransfer 的生产实践
如何在 Flink CDC 基础上通过 MongoDB Change Streams 特性实现 Flink MongoDB CDC Connector。
Flink CDC 系列 - Flink MongoDB CDC 在 XTransfer 的生产实践
|
消息中间件 存储 分布式计算
Apache Doris 数据导入总览
Apache Doris 的数据导入功能是提供用户将数据导入到 Doris 中,导入成功之后,用户可以通过 Mysql 客户端使用SQL对数据进行查询分析。
1253 0
|
Python
Python编程:将驼峰命名转为小写下划线命名
Python编程:将驼峰命名转为小写下划线命名
426 0