mongoexport
导数据 数据同步 mongodb无自增id 数据断点
mongoexport — MongoDB Manual https://docs.mongodb.com/manual/reference/program/mongoexport/
[root@e dump]# mongoexport --port 27017 -u admin -p pwd -h 1.2.3.4 --db superpub --collection ask --type json --file /mnt/mongoexport/superpub-ask.json
2018-11-26T10:08:29.355+0800 error parsing command line options: unknown option "file"
2018-11-26T10:08:29.355+0800 try 'mongoexport --help' for more information
[root@e dump]# mongoexport --help
Usage:
mongoexport <options>
Export data from MongoDB in CSV or JSON format.
See http://docs.mongodb.org/manual/reference/program/mongoexport/ for more information.
general options:
--help print usage
--version print th e tool version and exit
verbosity options:
-v, --verbose=<level> more detailed log output (include multiple times for more verbosity, e.g. -vvvvv, or specify a numeric value, e.g. --verbose=N)
--quiet hide all log output
connection options:
-h, --host=<hostname> mongodb host to connect to (setname/host1,host2 for replica sets)
--port=<port> server port (can also use --host hostname:port)
authentication options:
-u, --username=<username> username for authentication
-p, --password=<password> password for authentication
--authenticationDatabase=<database-name> database that holds the user's credentials
--authenticationMechanism=<mechanism> authentication mechanism to use
namespace options:
-d, --db=<database-name> database to use
-c, --collection=<collection-name> collection to use
output options:
-f, --fields=<field>[,<field>]* comma separated list of field names (required for exporting CSV) e.g. -f "name,age"
--fieldFile=<filename> file with field names - 1 per line
--type=<type> the output format, either json or csv (defaults to 'json') (default: json)
-o, --out=<filename> output file; if not specified, stdout is used
--jsonArray output to a JSON array rather than one object per line
--pretty output JSON formatted to be human-readable
--noHeaderLine export CSV data without a list of field names at the first line
querying options:
-q, --query=<json> query filter, as a JSON string, e.g., '{x:{$gt:1}}'
--queryFile=<filename> path to a file containing a query filter (JSON)
-k, --slaveOk allow secondary reads if available (default true) (default: false)
--readPreference=<string>|<json> specify either a preference name or a preference json object
--forceTableScan force a table scan (do not use $snapshot)
--skip=<count> number of documents to skip
--limit=<count> limit the number of documents to export
--sort=<json> sort order, as a JSON string, e.g. '{x:1}'
--assertExists if specified, export fails if the collection does not exist (default: false)
[root@e dump]# mongoexport --port 27017 -u admin -p pwd -h 1.2.3.4 --db superpub --collection ask --type json --out /mnt/mongoexport/superpub-ask.json
2018-11-26T10:08:56.440+0800 error connecting to db server: server returned error on SASL authentication step: Authentication failed.
[root@e dump]# mongoexport –authenticationDatabase admin --port 27017 -u admin -p pwd -h 1.2.3.4 --db superpub --collection ask --type json --out /mnt/mongoexport/superpub-ask.json
2018-11-26T10:12:04.529+0800 too many positional arguments: [–authenticationDatabase admin]
2018-11-26T10:12:04.529+0800 try 'mongoexport --help' for more information
[root@e dump]# mongoexport --authenticationDatabase admin --port 27017 -u admin -p pwd -h 1.2.3.4 --db superpub --collection ask --type json --out /mnt/mongoexport/superpub-ask.json
2018-11-26T10:12:24.853+0800 connected to: 1.2.3.4:27017
2018-11-26T10:12:25.850+0800 [........................] superpub.ask 0/124339189 (0.0%)
2018-11-26T10:12:26.850+0800 [........................] superpub.ask 24000/124339189 (0.0%)
2018-11-26T10:12:27.850+0800 [........................] superpub.ask 32000/124339189 (0.0%)
2018-11-26T10:12:28.850+0800 [........................] superpub.ask 56000/124339189 (0.0%)
2018-11-26T10:12:29.850+0800 [........................] superpub.ask 64000/124339189 (0.1%)
2018-11-26T10:12:30.851+0800 [........................] superpub.ask 88000/124339189 (0.1%)
2018-11-26T10:12:31.850+0800 [........................] superpub.ask 96000/124339189 (0.1%)
2018-11-26T10:12:32.850+0800 [........................] superpub.ask 120000/124339189 (0.1%)
2018-11-26T10:12:33.850+0800 [........................] superpub.ask 136000/124339189 (0.1%)
2018-11-26T10:12:34.850+0800 [........................] superpub.ask 160000/124339189 (0.1%)
2018-11-26T10:12:35.850+0800 [........................] superpub.ask 168000/124339189 (0.1%)
2018-11-26T10:12:36.850+0800 [........................] superpub.ask 192000/124339189 (0.2%)
2018-11-26T10:12:37.850+0800 [........................] superpub.ask 208000/124339189 (0.2%)
2018-11-26T10:12:38.850+0800 [........................] superpub.ask 224000/124339189 (0.2%)
2018-11-26T10:12:39.850+0800 [........................] superpub.ask 240000/124339189 (0.2%)
2018-11-26T10:12:40.850+0800 [........................] superpub.ask 264000/124339189 (0.2%)
2018-11-26T10:12:41.850+0800 [........................] superpub.ask 280000/124339189 (0.2%)
2018-11-26T10:12:42.850+0800 [........................] superpub.ask 296000/124339189 (0.2%)
2018-11-26T10:12:43.850+0800 [........................] superpub.ask 312000/124339189 (0.3%)
2018-11-26T10:12:44.850+0800 [........................] superpub.ask 336000/124339189 (0.3%)
2018-11-26T10:12:45.850+0800 [........................] superpub.ask 352000/124339189 (0.3%)
2018-11-26T10:12:46.850+0800 [........................] superpub.ask 368000/124339189 (0.3%)
2018-11-26T10:12:47.850+0800 [........................] superpub.ask 384000/124339189 (0.3%)
2018-11-26T10:12:48.850+0800 [........................] superpub.ask 392000/124339189 (0.3%)
2018-11-26T10:12:49.850+0800 [........................] superpub.ask 400000/124339189 (0.3%)
2018-11-26T10:12:50.850+0800 [........................] superpub.ask 400000/124339189 (0.3%)
2018-11-26T10:12:51.850+0800 [........................] superpub.ask 432000/124339189 (0.3%)
2018-11-26T10:12:52.850+0800 [........................] superpub.ask 440000/124339189 (0.4%)
2018-11-26T10:12:53.854+0800 [........................] superpub.ask 464000/124339189 (0.4%)
2018-11-26T10:12:54.850+0800 [........................] superpub.ask 472000/124339189 (0.4%)
2018-11-26T10:12:55.850+0800 [........................] superpub.ask 496000/124339189 (0.4%)
2018-11-26T10:12:56.850+0800 [........................] superpub.ask 504000/124339189 (0.4%)
2018-11-26T10:12:57.851+0800 [........................] superpub.ask 520000/124339189 (0.4%)
2018-11-26T10:12:58.850+0800 [........................] superpub.ask 528000/124339189 (0.4%)
2018-11-26T10:12:59.850+0800 [........................] superpub.ask 536000/124339189 (0.4%)
2018-11-26T10:13:00.850+0800 [........................] superpub.ask 544000/124339189 (0.4%)
2018-11-26T10:13:01.850+0800 [........................] superpub.ask 552000/124339189 (0.4%)
2018-11-26T10:13:02.850+0800 [........................] superpub.ask 560000/124339189 (0.5%)
2018-11-26T10:13:03.850+0800 [........................] superpub.ask 568000/124339189 (0.5%)
2018-11-26T10:13:04.850+0800 [........................] superpub.ask 576000/124339189 (0.5%)
2018-11-26T10:13:05.850+0800 [........................] superpub.ask 608000/124339189 (0.5%)
2018-11-26T10:13:06.850+0800 [........................] superpub.ask 624000/124339189 (0.5%)
2018-11-26T10:13:07.850+0800 [........................] superpub.ask 640000/124339189 (0.5%)
2018-11-26T10:13:08.850+0800 [........................] superpub.ask 656000/124339189 (0.5%)
2018-11-26T10:13:09.850+0800 [........................] superpub.ask 664000/124339189 (0.5%)
2018-11-26T10:13:10.850+0800 [........................] superpub.ask 672000/124339189 (0.5%)
2018-11-26T10:13:11.850+0800 [........................] superpub.ask 688000/124339189 (0.6%)
2018-11-26T10:13:12.861+0800 [........................] superpub.ask 704000/124339189 (0.6%)
2018-11-26T10:13:13.850+0800 [........................] superpub.ask 712000/124339189 (0.6%)
2018-11-26T10:13:14.850+0800 [........................] superpub.ask 720000/124339189 (0.6%)
2018-11-26T10:13:15.850+0800 [........................] superpub.ask 728000/124339189 (0.6%)
2018-11-26T10:13:16.850+0800 [........................] superpub.ask 736000/124339189 (0.6%)
2018-11-26T10:13:17.850+0800 [........................] superpub.ask 736000/124339189 (0.6%)
2018-11-26T10:13:18.850+0800 [........................] superpub.ask 744000/124339189 (0.6%)
制定字段导出
mongoexport --authenticationDatabase admin --port 27017 -u admin -p pwd123 -h 1.2.3.4 --db superpub --collection ask --type csv --fields "question,answer" --out /mnt/mongoexport/superpub-ask-q-a.csv
mongoexport的更多相关文章
- MongoDB导入(mongoimport)-导出(mongoexport)工具使用
1.导出工具-mongoexport Mongodb中的mongoexport工具可以把一个collection导出为JSON格式或者CSV格式文件. (1).导出为JSON文件 /opt/mongo ...
- MongoDB 备份(mongodump)恢复(mongorerstore) 导出 (Mongoexport) 导入( Mongoimport)
MongoDB 备份(mongodump) 在Mongodb中我们使用mongodump命令来备份MongoDB数据.该命令可以导出所有数据到指定目录中. mongodump命令可以通过参数指定导出的 ...
- Mongodb数据导出工具mongoexport和导入工具mongoimport介绍
一.导出工具mongoexport Mongodb中的mongoexport工具可以把一个collection导出成JSON格式或CSV格式的文件.可以通过参数指定导出的数据项,也可以根据指定的条件导 ...
- 【MongoDB】mongoimport and mongoexport of data (一)
In the software development, we usually are faced with a common question of exporting or importing d ...
- Mongo的导出工具mongoexport介绍
需求介绍:将mongodb中的数据以文件的方式导出:json或cvs格式 mongo 提供了mongoexport的工具,可以实现将库中的数据以json或cvs的格式输出到文件中.mongoexpor ...
- mongoexport导出数据
mongoexport用法: /***** Export MongoDB data to CSV, TSV or JSON files.options: --help ...
- MongoDB 执行mongoexport时异常及分析(关于数字类型的查询)
今天在用mongoexport导出满足一定条件下的数据时,遇到了一个报错,现纪录下来,并且针对此错误对MongoDB 的 数字类型 做了进一步的学习. 背景 及 报错信息 今天接到一个业务需求,需要从 ...
- mongoexport 导出需要授权数据库中的集合 报错 Authentication failed.
当 mongo数据库启动服务时,使用了 认证机制,在使用mongoexport导出集合文件时,需要用户权限认证. 开启数据库认证服务: mongod --auth 导出mongo中集合文件: mong ...
- MongoExport后的负载均衡问题查询及解决:can't accept new chunks because there are still 2 deletes from previous migration
问题 前一阵有一个数据导出需求,按照各种数据库的使用方法,使用MongoExport方法导出数据,将数据导出到本地文件系统,在导出之后遇到此问题. 此问题和mongoexport的原理有关,我们知道数 ...
- mongo数据的导入(mongoimport)和导出(mongoexport)
1.导出数据可以使用命令: mongoexport -h dbhost -d dbname -c collectionName -o output 参数说明: -h 数据库地址 -d 指明使用的库 - ...
随机推荐
- VS2010 快捷键设置,快速编码1
全屏:Shift+Alt+Enter注释选定内容:Ctrl+E+C/Crtr+E+U代码格式化:ctrl+E+F VS2008 使用小技巧——快捷键1. 怎样调整代码排版的格式?选择:编辑—>高 ...
- (转)RGB接口和i80接口的区别
在嵌入式的主流 LCD屏中主要支持两大类的硬件接口,一种是常见的RGB接口,另外一种是MCU接口.后面因为最早是针对单片机的领域在使用,因此得名.后在中低端手机大量使用,其主要特点是价格便宜的. M ...
- 初涉RxAndroid结合Glide实现多图片载入操作
转载请注明出处:王亟亟的大牛之路 本来周末就想发了然后各种拖拉就没有然后了,那么就今天早上写吧,废话不多開始正题 什么是RxJava或者RxAndroid我就不多废话了,理论知识一大堆人给我们做好了. ...
- spring FactoryBean配置Bean
概要: 实例代码具体解释: 文件夹结构 Car.java package com.coslay.beans.factorybean; public class Car { private String ...
- NET Core 环境搭建和命令行CLI入门[转]
NET Core 环境搭建和命令行CLI入门 时间:2016-07-06 01:48:19 阅读:258 评论:0 收藏:0 [点我收藏+] 标签: N ...
- ueditor1.4.3配置过程(包含单独上传文件以及图片的使用),ueditor1.4.3上传配置(转 http://www.bkjia.com/webzh/1001016.html)
这里使用的是ueditor1.4.3的jsp版本的UTF-8版本. 首先下载相应的ueditor,将ueditor文件夹直接拷贝到项目中,文件结构如下所示: 然后将项目要用的jar包导入到lib目录下 ...
- OpenCV学习:图像的载入和显示
一.使用IplImage结构读取并显示图像文件: 运行结果: 二.使用Mat类读取并显示图像文件: 使用 Mat 类,内存管理变得简单,不再像使用 IplImage 那样需要自己申请和释放内存,而且一 ...
- JavaScript正则表达式1
在编写处理字符串的程序或网页时,经常会有查找符合某些复杂规则的字符串的需要.正则表达式就是用于描述这些规则的工具.换句话说,正则表达式就是记录文本规则的代码. 正则表达式可以: •数据有效性验证.可以 ...
- JQuery--使用autocomplete控件进行自己主动输入完毕(相当于模糊查询)
之前为了实现这个功能花了我几天的时间. 事实上.实现了之后发现也就那么回事,正所谓万事开头难嘛.. 废话不多说了.这里我使用的是JQuery控件库中的一个Autocomplete控件.即Autocom ...
- IM软件业务知识—导航
----------------------------------------------------欢迎查看IM软件业务知识<专栏>-------------------------- ...