本文档适用于 mongoexport 的 100.18.0 版本。
Synopsis
mongoexport 是一个数据库工具,它可将 MongoDB 实例中存储的数据导出为 JSON 或 CSV。
Run mongoexport from the system command line, not the mongo shell.
mongoexport 不是用于备份部署的工具。如果要创建备份解决方案,请参阅使用 MongoDB 工具备份和恢复。
提示
mongoimport 而它提供了相应的结构化数据
导入功能。
注意
如果要存档过时数据以节省存储成本,请考虑MongoDB Atlas中的 Online 存档 。 Online 存档会自动将不常访问的数据存档到完全托管的S3 存储桶,以实现经济高效的数据分层。
您可以使用 Database Tools 从自托管部署迁移到 MongoDB Atlas。MongoDB Atlas 是用于云中 MongoDB 部署的完全托管服务。要了解详情,请参阅使用 mongorestore 播种。
要了解迁移到 MongoDB Atlas 的所有方法,请参阅迁移或导入数据。
语法
mongoexport 事务语法:
mongoexport --collection=<coll> <options> <connection-string>
You must specify the collection to export. If you do not specify an output file, mongoexport writes to the standard output (e.g. stdout).
连接到 MongoDB 实例
要连接到端口 27017 上所运行的本地 MongoDB 实例,您不必指定主机或端口。
示例,要将指定的 从在端口collection output file上运行的本地MongoDB实例导出到指定的27017 :
mongoexport --collection=events --db=reporting --out=events.json
要指定 MongoDB 实例的主机和/或端口,可以执行以下任一操作:
Specify the hostname and port in the
--uri connection string:mongoexport --uri="mongodb://mongodb0.example.com:27017/reporting" --collection=events --out=events.json [additional options] When using the
--uri connection string, the database can be specified as part of the string.Specify the hostname and port in the
--host:mongoexport --host="mongodb0.example.com:27017" --collection=events --db=reporting --out=events.json [additional options]
有关可用选项的更多信息,请参阅选项。
连接到副本集
注意
mongoexport 不是用于备份数据的工具。要备份副本集,请参阅使用 MongoDB 工具备份和恢复。
要连接到副本集以导出其数据,可以执行以下任一操作:
Specify the replica set name and members in the
--uri connection string:mongoexport --uri="mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/reporting?replicaSet=myReplicaSetName" --collection=events --out=events.json [additional options] When using the
--uri connection string, the database can be specified as part of the string.Specify the replica set name and members in the
--host:mongoexport --host="myReplicaSetName/mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com" --collection=events --db=reporting --out=events.json [additional options]
默认情况下, mongoexport从副本集的主节点读取。 要覆盖默认值,可以指定读取偏好:
可以在以下语句中指定读取偏好:
--uri connection stringmongoexport --uri="mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/reporting?replicaSet=myReplicaSetName&readPreference=secondary" --collection=events --out=events.json [additional options] If specifying the read preference tags, include the
readPreferenceTagsoption:mongoexport --uri="mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/reporting?replicaSet=myReplicaSetName&readPreference=secondary&readPreferenceTags=region:east" --collection=events --out=events.json [additional options] When using the
--uri connection string, the database can be specified as part of the string.You can specify the read preference using the
--readPreferencecommand-line option. The command-line option takes a string if specifying only the read preference mode:mongoexport --host="myReplicaSetName/mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017" --readPreference=secondary --collection=events --db=reporting --out=events.json [additional options] 或者,该命令行选项可使用用引号括起的文档
'{ mode: <mode>, tagSets: [ <tag1>, ... ], maxStalenessSeconds:<num>}'来指定模式、可选读取偏好标签集和可选 maxStalenessSeconds:mongoexport --host="myReplicaSetName/mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017" --readPreference='{mode: "secondary", tagSets: [ { "region": "east" } ]}' --collection=events --db=reporting --out=events.json [additional options]
有关可用选项的更多信息,请参阅选项。
连接到分片集群
注意
mongoexport 不是用于备份数据的工具。要备份分片集群,请参阅备份和恢复自管理分片集群。
要连接到分片集群以导出其数据,可以执行以下任一操作:
Specify the hostname of the
mongosinstance in the--uri connection stringmongoexport --uri="mongodb://mongos0.example.com:27017/reporting" --collection=events --out=events.json [additional options] When using the
--uri connection string, the database can be specified as part of the string.
默认情况下,mongoexport 从分片副本集的主节点中读取。要覆盖默认值,可以指定读取偏好:
可以在以下语句中指定读取偏好:
--uri connection stringmongoexport --uri="mongodb://mongos0.example.com:27017/reporting?readPreference=secondary" --collection=events --out=events.json [additional options] If specifying the read preference tags, include the
readPreferenceTagsoption:mongoexport --uri="mongodb://mongos0.example.com:27017/reporting?readPreference=secondary&readPreferenceTags=region:east" --collection=events --out=events.json [additional options] When using the
--uri connection string, the database can be specified as part of the string.You can specify the read preference using the
--readPreferencecommand-line option. The command-line option takes a string if specifying only the read preference mode:mongoexport --host="mongos0.example.com:27017" --readPreference=secondary --collection=events --db=reporting --out=events.json [additional options] 或者,该命令行选项可使用用引号括起的文档
'{ mode: <mode>, tagSets: [ <tag1>, ... ], maxStalenessSeconds:<num>}'来指定模式、可选读取偏好标签集和可选 maxStalenessSeconds:mongoexport --host="mongos0.example.com:27017" --readPreference='{mode: "secondary", tagSets: [ { "region": "east" } ]}' --collection=events --db=reporting --out=events.json [additional options]
选项
--quiet在尝试限制输出量的安静模式下运行
mongoexport。该选项会抑制:
Output from database commands
复制活动
已接受和已关闭的事件连接
所有日志,包括错误信息,解析选项时出现的错误信息除外
--config=<filename>100.3.0版本新增。
指定 YAML 配置文件的完整路径,该文件包含以下
mongoexport选项的敏感值:除通过密码提示来指定密码之外,这是为
mongoexport指定密码的另一推荐方法。您可以在文件中使用任何参数的组合。配置文件采用以下形式:
password: <password> uri: mongodb://mongodb0.example.com:27017 sslPEMKeyPassword: <password> 如果您指定了
password选项但未指定uri,则可以使用mongoexport命令行选项指定连接字符串的其他组件,例如--username和--host。请务必使用相应的文件系统权限保护此文件。
重要
使用
--config选项时,请注意以下限制和行为:如果您提供
password字段,并在uri字段中提供一个与密码冲突的连接字符串,则mongorestore会抛出错误。如果您使用
--config指定配置文件,并使用--password、--uri或--sslPEMKeyPasswordmongoexport命令行选项,则命令行选项将覆盖相应的配置文件选项。
--uri=<connectionString>指定 MongoDB 部署的可解析 URI 连接字符串(用引号括起):
--uri="mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]" Starting with version
100.0ofmongoexport, the connection string may alternatively be provided as a positional parameter, without using the--urioption:mongoexport mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]] 作为位置参数,可以在命令行上的任何位置指定连接字符串,前提是它以
mongodb://或mongodb+srv://开头。例如:mongoexport --username joe --password secret1 mongodb://mongodb0.example.com:27017 --ssl Only one connection string can be provided. Attempting to include more than one, whether using the
--urioption or as a positional argument, will result in an error.有关连接字符串的组件信息,请参阅连接字符串 URI 格式文档。
注意
connection string中的某些组件也可以使用各自的显式命令行选项来指定,例如--username和--password。在提供连接字符串的同时,使用显式选项并指定冲突信息会导致错误。注意
如果在Ubuntu 上使用
mongoexport18.04 ,则在使用带有 选项的cannot unmarshal DNSSRV 连接字符串(采用mongodb+srv://形式)时,您可能会遇到--uri错误消息。如果是这样,请改用以下选项之一:the
--urioption with a non-SRV connection string (in the formmongodb://)--host选项指定直接连接的主机
--host=<hostname><:port>, -h=<hostname><:port>默认:localhost:27017
指定 MongoDB 部署的可解析主机名。默认情况下,
mongoexport尝试连接到在本地主机端口号27017上运行的 MongoDB 实例。To connect to a replica set, specify the
replSetNameand a seed list of set members, as in the following:--host=<replSetName>/<hostname1><:port>,<hostname2><:port>,<...> 指定副本集列表格式时,
mongoexport始终连接到主节点。还可以通过仅指定该成员的主机和端口来连接至副本集的任何单个成员:
--host=<hostname1><:port> 如果您使用 IPv6 并采用
<address>:<port>格式,则须将地址与端口的组合部分用方括号括起(即[<address>])。或者,也可直接在
URI connection string中指定主机名。在使用--host的同时提供连接字符串并指定冲突信息将导致错误。
--port=<port>默认值:27017
指定 MongoDB 实例侦听客户端连接的 TCP 端口。
或者,也可以直接在
URI connection string中指定端口。在提供连接字符串的同时使用--port并指定冲突信息将导致错误。
--sslEnables connection to a
mongodormongosthat has TLS/SSL support enabled.或者,也可以直接在
URI connection string中配置 TLS/SSL 支持。在提供连接字符串的同时使用--ssl并指定冲突信息将导致错误。有关 TLS/SSL 和 MongoDB 的更多信息,请参阅为 TLS/SSL 配置 mongod 和 mongos 和客户端的 TLS/SSL 配置。
--sslCAFile=<filename>指定包含来自证书颁发机构的根证书链的
.pem文件。使用相对或绝对路径指定.pem文件的文件名。或者,也可以直接在
URI connection string中指定.pem文件。在提供连接字符串的同时使用--sslCAFile并指定冲突信息将导致错误。有关 TLS/SSL 和 MongoDB 的更多信息,请参阅为 TLS/SSL 配置 mongod 和 mongos 和客户端的 TLS/SSL 配置。
--sslPEMKeyFile=<filename>指定同时包含 TLS/SSL 证书和密钥的
.pem文件。使用相对或绝对路径指定.pem文件的文件名。This option is required when using the
--ssloption to connect to amongodormongosthat hasCAFileenabled withoutallowConnectionsWithoutCertificates.或者,也可以直接在
URI connection string中指定.pem文件。在提供连接字符串的同时使用--sslPEMKeyFile并指定冲突信息将导致错误。有关 TLS/SSL 和 MongoDB 的更多信息,请参阅为 TLS/SSL 配置 mongod 和 mongos 和客户端的 TLS/SSL 配置。
--sslPEMKeyPassword=<value>Specifies the password to de-crypt the certificate-key file (i.e.
--sslPEMKeyFile). Use the--sslPEMKeyPasswordoption only if the certificate-key file is encrypted. In all cases, themongoexportwill redact the password from all logging and reporting output.If the private key in the PEM file is encrypted and you do not specify the
--sslPEMKeyPasswordoption, themongoexportwill prompt for a passphrase. See TLS/SSL Certificate Passphrase.或者,也可以直接在
URI connection string中指定密码。在提供连接字符串的同时使用--sslPEMKeyPassword并指定冲突信息将导致错误。有关 TLS/SSL 和 MongoDB 的更多信息,请参阅为 TLS/SSL 配置 mongod 和 mongos 和客户端的 TLS/SSL 配置。
警告
在某些系统上,直接使用
--sslPEMKeyPassword选项提供的密码,可能会被其他用户调用的系统状态程序(如ps)探测到。可以考虑使用--config选项,指定一个包含密码的配置文件。
--sslCRLFile=<filename>指定包含证书吊销列表的
.pem文件。使用相对或绝对路径指定.pem文件的文件名。有关 TLS/SSL 和 MongoDB 的更多信息,请参阅为 TLS/SSL 配置 mongod 和 mongos 和客户端的 TLS/SSL 配置。
--sslAllowInvalidCertificatesBypasses the validation checks for server certificates and allows the use of invalid certificates. When using the
allowInvalidCertificatessetting, MongoDB logs as a warning the use of the invalid certificate.警告
尽管可用,但请尽可能避免使用
--sslAllowInvalidCertificates选项。如果需要使用--sslAllowInvalidCertificates,请仅在不可能入侵的系统上使用该选项。Connecting to a
mongodormongosinstance without validating server certificates is a potential security risk. If you only need to disable the validation of the hostname in the TLS/SSL certificates, see--sslAllowInvalidHostnames.或者,也可以直接在
URI connection string中禁用证书验证。在提供连接字符串的同时使用--sslAllowInvalidCertificates并指定冲突信息将导致错误。有关 TLS/SSL 和 MongoDB 的更多信息,请参阅为 TLS/SSL 配置 mongod 和 mongos 和客户端的 TLS/SSL 配置。
--sslAllowInvalidHostnames禁用 TLS/SSL 证书中的主机名验证。即使证书中的主机名与指定的主机名不匹配,也支持
mongoexport连接到 MongoDB 实例。或者,也可以直接在
URI connection string中禁用主机名验证。在提供连接字符串的同时使用--sslAllowInvalidHostnames并指定冲突信息将导致错误。有关 TLS/SSL 和 MongoDB 的更多信息,请参阅为 TLS/SSL 配置 mongod 和 mongos 和客户端的 TLS/SSL 配置。
--username=<username>, -u=<username>Specifies a username with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the
--passwordand--authenticationDatabaseoptions.或者,也可直接在
URI connection string中指定用户名。在使用--username的同时提供连接字符串并指定冲突信息将导致错误。If connecting to a MongoDB Atlas cluster using the
MONGODB-AWSauthentication mechanism, you can specify your AWS access key ID in:这个字段,
the
connection string, orAWS_ACCESS_KEY_ID环境变量。
请参阅使用 AWS IAM 凭据连接到 MongoDB Atlas 集群,了解每个凭据的示例。
--password=<password>, -p=<password>Specifies a password with which to authenticate to a MongoDB database that uses authentication. Use in conjunction with the
--usernameand--authenticationDatabaseoptions.To prompt the user for the password, pass the
--usernameoption without--passwordor specify an empty string as the--passwordvalue, as in--password "".或者,也可以直接在
URI connection string中指定密码。在提供连接字符串的同时使用--password并指定冲突信息将导致错误。If connecting to a MongoDB Atlas cluster using the
MONGODB-AWSauthentication mechanism, you can specify your AWS secret access key in:这个字段,
the
connection string, orAWS_SECRET_ACCESS_KEY环境变量。
请参阅使用 AWS IAM 凭据连接到 MongoDB Atlas 集群,了解每个凭据的示例。
警告
在某些系统上,直接使用
--password选项提供的密码,可能会被其他用户调用的系统状态程序(如ps)探测到。请考虑:省略
--password选项以接收交互式密码提示,或使用
--config选项指定包含密码的配置文件。
--awsSessionToken=<AWS Session Token>If connecting to a MongoDB Atlas cluster using the
MONGODB-AWSauthentication mechanism, and using session tokens in addition to your AWS access key ID and secret access key, you can specify your AWS session token in:这个字段,
the
AWS_SESSION_TOKENauthMechanismPropertiesparameter to theconnection string, orAWS_SESSION_TOKEN环境变量。
请参阅使用 AWS IAM 凭据连接到 MongoDB Atlas 集群,了解每个凭据的示例。
仅在使用
MONGODB-AWSauthentication mechanism时有效。
--authenticationDatabase=<dbname>Specifies the authentication database where the specified
--usernamehas been created. See Authentication Database.如果未指定身份验证数据库,
mongoexport将假定指定要导出的数据库保存用户凭证。If you use the GSSAPI (Kerberos), PLAIN (LDAP SASL), or
MONGODB-AWSauthentication mechanisms, you must set--authenticationDatabaseto$external.或者,也可以直接在
URI connection string中指定身份验证数据库。在提供连接字符串的同时使用--authenticationDatabase并指定冲突信息,将导致错误。
--authenticationMechanism=<name>默认值:SCRAM-SHA-1
Specifies the authentication mechanism the
mongoexportinstance uses to authenticate to themongodormongos.Changed in version 100.1.0:
从版本
100.1.0开始,mongoexport添加了在连接 MongoDB Atlas 集群时对MONGODB-AWS身份验证机制的支持。值说明RFC 5802 standard Salted Challenge Response Authentication Mechanism using the SHA-1 hash function.
RFC 7677 standard Salted Challenge Response Authentication Mechanism using the SHA-256 hash function.
需将 featureCompatibilityVersion 设为
4.0。MongoDB TLS/SSL 证书身份验证。
MONGODB-AWS使用 AWS IAM 凭据进行外部身份验证,用于连接到 MongoDB Atlas 集群。请参阅使用 AWS IAM 凭证连接到 MongoDB Atlas 集群。
100.1.0版本新增。
GSSAPI (Kerberos)
使用 Kerberos 的外部身份验证。此机制仅在 MongoDB Enterprise 中可用。
普通版 (LDAP SASL)
使用 LDAP 进行外部身份验证。您也可使用
PLAIN对数据库内用户进行身份验证。PLAIN以纯文本形式传输密码。此机制仅在 MongoDB Enterprise 中可用。或者,也可以直接在
URI connection string中指定身份验证机制。在提供连接字符串的同时使用--authenticationMechanism并指定冲突信息,将导致错误。
--gssapiServiceName=<serviceName>Specify the name of the service using GSSAPI/Kerberos. Only required if the service does not use the default name of
mongodb.此选项仅在 MongoDB Enterprise 中可用。
--gssapiHostName=<hostname>使用 GSSAPI/Kerberos 指定服务的主机名。仅当机器的主机名与 DNS 解析的主机名不匹配时才需要。
此选项仅在 MongoDB Enterprise 中可用。
--db=<database>, -d=<database>指定要在其上运行
mongoexport的数据库的名称。或者也可以直接在
URI connection string中指定数据库。在提供连接字符串的同时使用--db并指定冲突信息将导致错误。
--fields=<field1[,field2]>, -f=<field1[,field2]>指定要包含在 导出中的一个或多个字段。使用逗号分隔的字段列表指定多个字段。
如果任一字段名称包含空格,请使用引号将字段列表括起来。例如,如果希望导出两个字段
phone和user number,则应指定--fields "phone,user number"。For
csvoutput formats,mongoexportincludes only the specified field(s), and the specified field(s) can be a field within a sub-document.For JSON output formats,
mongoexportincludes only the specified field(s) and the_idfield, and if the specified field(s) is a field within a sub-document, themongoexportincludes the sub-document with all its fields, not just the specified field within the document.有关示例用法,请参阅:使用
--fields选项以 CSV 格式导出数据。
--fieldFile=<filename>An alternative to
--fields. The--fieldFileoption allows you to specify in a file the field or fields to include in the export and is only valid with the--typeoption with valuecsv. The file must have only one field per line, and the line(s) must end with the LF character (0x0A).mongoexport仅包括指定的字段。 指定的字段可以是子文档中的字段。有关示例用法,请参阅使用文件指定要以 CSV 格式导出的字段。
--query=<JSON>, -q=<JSON>以 JSON 文档(用引号括起)的形式提供查询,以在导出时返回匹配的文档。
必须用单引号 (
'{ ... }') 括起查询文档,确保它不会与 shell 环境交互。查询必须采用扩展JSON v2 格式(宽松模式或规范/严格模式),包括用引号将字段名称和操作符括起来:
例如,数据库
records中名为test的集合包含以下文档:{ "_id" : ObjectId("51f0188846a64a1ed98fde7c"), "a" : 1, "date" : ISODate("1960-05-01T00:00:00Z") } { "_id" : ObjectId("520e61b0c6646578e3661b59"), "a" : 1, "b" : 2, "date" : ISODate("1970-05-01T00:00:00Z") } { "_id" : ObjectId("520e642bb7fa4ea22d6b1871"), "a" : 2, "b" : 3, "c" : 5, "date" : ISODate("2010-05-01T00:00:00Z") } { "_id" : ObjectId("520e6431b7fa4ea22d6b1872"), "a" : 3, "b" : 3, "c" : 6, "date" : ISODate("2015-05-02T00:00:00Z") } { "_id" : ObjectId("520e6445b7fa4ea22d6b1873"), "a" : 5, "b" : 6, "c" : 8, "date" : ISODate("2018-03-01T00:00:00Z") } { "_id" : ObjectId("5cd0de910dbce4346295ae28"), "a" : 15, "b" : 5, "date" : ISODate("2015-03-01T00:00:00Z") } 以下
mongoexport-qa$gte使用3date$ltISODate("2016-01-01T00:00:00Z")选项,仅导出字段 大于或等于 ( ) 且字段 小于 ( ) ,它是使用日期2 ({ "$date": "YYYY-MM-DDTHH:mm:ss.mmm\<offset\>"}) 的扩展JSON v 格式(宽松模式)指定的:mongoexport -d=test -c=records -q='{ "a": { "$gte": 3 }, "date": { "$lt": { "$date": "2016-01-01T00:00:00.000Z" } } }' --out=exportdir/myRecords.json 生成的文件包含以下文档:
{"_id":{"$oid":"520e6431b7fa4ea22d6b1872"},"a":3.0,"b":3.0,"c":6.0,"date":{"$date":"2015-05-02T00:00:00Z"}} {"_id":{"$oid":"5cd0de910dbce4346295ae28"},"a":15.0,"b":5.0,"date":{"$date":"2015-03-01T00:00:00Z"}} You can sort the results with the
--sortoption tomongoexport.从MongoDB9.0 开始,当路径的中间组件是标量值大量时,服务器将以不同方式将虚线字段路径与
null进行匹配。此更改会影响$eq、$ne、$in和$nin操作符。例如,考虑包含文档
{ "a": [ 1 ] }的集合。该文档中不存在路径a.b。在 MongoDB 8.x 及更早版本中,谓词
{ "a.b": { "$ne": null } }匹配文档。从 MongoDB 9.0 开始,相同的谓词不匹配文档,而是由谓词
{ "a.b": { "$eq": null } }匹配。
如果您的查询使用此类谓词,则相同的
--query值在 MongoDB 9.0 上选择的文档集与早期版本上选择的文档集不同。对{ "$ne": null }进行过滤的操作返回的文档数量较少。在从 MongoDB 9.0 部署中转储或导出数据之前,请查看将点分路径与null进行比较的任何查询。确认查询仍然选择您预期的文档。
--queryFile=<filename>--query--queryFile的替代方案。 选项允许您在文件中指定扩展JSON v 格式的查询。2
--type=<string>Default: json
Specifies the file type to export. Specify
csvfor CSV format orjsonfor JSON format.If you specify
csv, then you must also use either the--fieldsor the--fieldFileoption to declare the fields to export from the collection.
--jsonFormat=<canonical|relaxed>默认:宽松
修改输出以使用MongoDB扩展JSON (v)2 格式的规范或宽松模式。
--jsonArrayModifies the output of
mongoexportto write the entire contents of the export as a single JSON array. By defaultmongoexportwrites data using one JSON document for every MongoDB document.
--noHeaderLineBy default,
mongoexportincludes the exported field names as the first line in a CSV output.--noHeaderLinedirectsmongoexportto export the data without the list of field names.--noHeaderLineis only valid with the--typeoption with valuecsv.有关示例用法,请参阅从 CSV 输出中排除字段名称。
--readPreference=<string|document>Default:
primarySpecifies the read preference for
mongoexport. The--readPreferenceoption can take:如果仅指定读取偏好模式,则为一个字符串:
--readPreference=secondary 用引号括起的文档,用于指定模式、可选的读取偏好标签集以及可选的 maxStalenessSeconds:
--readPreference='{mode: "secondary", tagSets: [ { "region": "east" } ], maxStalenessSeconds: 120}' If specifying the maxStalenessSeconds, the value must be greater than or equal to 90.
mongoexportdefaults toprimaryread preference.If the read preference is also included in the
--uri connection string, the command-line--readPreferenceoverrides the read preference specified in the URI string.
--skip=<number>Use
--skipto control wheremongoexportbegins exporting documents. Seeskip()for information about the underlying operation.
--limit=<number>Specifies a maximum number of documents to include in the export. See
limit()for information about the underlying operation.
--sort=<JSON>指定导出结果的顺序。如果不存在可以支持排序操作的索引,则结果必须小于 32 MB。
Use
--sortconjunction with--skipand--limitto limit number of exported documents.mongoexport -d=test -c=records --sort='{a: 1}' --limit=100 --out=export.0.json mongoexport -d=test -c=records --sort='{a: 1}' --limit=100 --skip=100 --out=export.1.json mongoexport -d=test -c=records --sort='{a: 1}' --limit=100 --skip=200 --out=export.2.json See
sort()for information about the underlying operation.