【MongoDB】mongoimport mongoexport
2017-06-15 19:51
330 查看
mongoexport:将数据导出成JSON格式,与标准的JSON有些不同
参数说明:
[root@localhost mongodb]# ./bin/mongoexport –help
Export MongoDB data to CSV, TSV or JSON files.
options:
–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 ( /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)
-f [ –fields ] arg comma separated list of field names e.g. -f name,age
–fieldFile arg file with fields names - 1 per line
-q [ –query ] arg query filter, as a JSON string
–csv export to csv instead of json
-o [ –out ] arg output file; if not specified, stdout is used
–jsonArray output to a json array rather than one object per line
-k [ –slaveOk ] arg (=1) use secondaries for export if available, default true
常用: mongoexport -d testdb -c testcol -o out.dat
mongoimport:从JSON导入,由于与标准的JSON略有些不同,如果出现错误,可以先导出看看mongo的格式要求,再导入
[root@localhost mongodb]# ./bin/mongoimport –help
options:
–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 ( /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)
-f [ –fields ] arg comma separated list of field names e.g. -f name,age
–fieldFile arg file with fields names - 1 per line
–ignoreBlanks if given, empty fields in csv and tsv will be ignored
–type arg type of file to import. default: json (json,csv,tsv)
–file arg file to import from; if not specified stdin is used
–drop drop collection first
–headerline CSV,TSV only - use first line as headers
–upsert insert or update objects that already exist
–upsertFields arg comma-separated fields for the query part of the upsert. You should make
sure this is indexed
–stopOnError stop importing at first error rather than continuing
–jsonArray load a json array, not one item per line. Currently limited to 4MB.
参数说明:
[root@localhost mongodb]# ./bin/mongoexport –help
Export MongoDB data to CSV, TSV or JSON files.
options:
–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 ( /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)
-f [ –fields ] arg comma separated list of field names e.g. -f name,age
–fieldFile arg file with fields names - 1 per line
-q [ –query ] arg query filter, as a JSON string
–csv export to csv instead of json
-o [ –out ] arg output file; if not specified, stdout is used
–jsonArray output to a json array rather than one object per line
-k [ –slaveOk ] arg (=1) use secondaries for export if available, default true
常用: mongoexport -d testdb -c testcol -o out.dat
mongoimport:从JSON导入,由于与标准的JSON略有些不同,如果出现错误,可以先导出看看mongo的格式要求,再导入
[root@localhost mongodb]# ./bin/mongoimport –help
options:
–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 ( /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)
-f [ –fields ] arg comma separated list of field names e.g. -f name,age
–fieldFile arg file with fields names - 1 per line
–ignoreBlanks if given, empty fields in csv and tsv will be ignored
–type arg type of file to import. default: json (json,csv,tsv)
–file arg file to import from; if not specified stdin is used
–drop drop collection first
–headerline CSV,TSV only - use first line as headers
–upsert insert or update objects that already exist
–upsertFields arg comma-separated fields for the query part of the upsert. You should make
sure this is indexed
–stopOnError stop importing at first error rather than continuing
–jsonArray load a json array, not one item per line. Currently limited to 4MB.
相关文章推荐
- mongodb数据导入导出mongoexport/mongoimport
- mongodb数据导入导出mongoexport/mongoimport
- 【MongoDB】mongoimport and mongoexport of data (二)
- MongoDB mongoimport 工具 批量 导入 json 文档,小问题
- MongoDB mongoimport 报错:lost connection to server
- mongoDB 数据导出之mongoexport的用法
- MongoDB用mongoimport导入大文件报错
- ES-MongoDB学习错误1_Could not import mongo_connector.doc_managers.elastic_doc_manager
- mongodb导出数据表命令之mongoexport
- mongoDB:mongoimport数据导入的问题
- mongodb mongoexport
- Db2 文件导入导出常见命令总结 EXPORT IMPORT LOAD
- hbase的export与import工具
- mongodb源码分析(三)mongo的启动
- 转载自雅飞士个人博客 本文链接地址: http://blog.yafeishi.net/2012/12/stat-export-import.html
- [转] ES6 import/export:模块导入导出方式
- dll import&&export
- 连接mongo的服务提示:HTTP Status 500 - com.mongodb.MongoException$Network: can't call something
- 5-4 import,export属性
- MongoDB - The mongo Shell, Write Scripts for the mongo Shell