Blame SOURCES/mongoimport.1

c34f3f
.\" Man page generated from reStructuredText.
c34f3f
.
c34f3f
.TH "MONGOIMPORT" "1" "January 30, 2015" "3.0" "mongodb-manual"
c34f3f
.SH NAME
c34f3f
mongoimport \- MongoDB Import Utility
c34f3f
.
c34f3f
.nr rst2man-indent-level 0
c34f3f
.
c34f3f
.de1 rstReportMargin
c34f3f
\\$1 \\n[an-margin]
c34f3f
level \\n[rst2man-indent-level]
c34f3f
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
c34f3f
-
c34f3f
\\n[rst2man-indent0]
c34f3f
\\n[rst2man-indent1]
c34f3f
\\n[rst2man-indent2]
c34f3f
..
c34f3f
.de1 INDENT
c34f3f
.\" .rstReportMargin pre:
c34f3f
. RS \\$1
c34f3f
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
c34f3f
. nr rst2man-indent-level +1
c34f3f
.\" .rstReportMargin post:
c34f3f
..
c34f3f
.de UNINDENT
c34f3f
. RE
c34f3f
.\" indent \\n[an-margin]
c34f3f
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
c34f3f
.nr rst2man-indent-level -1
c34f3f
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
c34f3f
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
c34f3f
..
c34f3f
.SH SYNOPSIS
c34f3f
.sp
c34f3f
The \fBmongoimport\fP tool provides a route to import content from a
c34f3f
JSON, CSV, or TSV export created by \fBmongoexport\fP, or
c34f3f
potentially, another third\-party export tool. See the
c34f3f
http://docs.mongodb.org/manual/core/import\-export document for a more in depth
c34f3f
usage overview, and the \fBmongoexport\fP document for more
c34f3f
information regarding \fBmongoexport\fP, which
c34f3f
provides the inverse "exporting" capability.
c34f3f
.SH CONSIDERATIONS
c34f3f
.sp
c34f3f
Do not use \fBmongoimport\fP and \fBmongoexport\fP for
c34f3f
full instance, production backups because they will not reliably capture data type
c34f3f
information. Use \fBmongodump\fP and \fBmongorestore\fP as
c34f3f
described in http://docs.mongodb.org/manual/core/backups for this kind of
c34f3f
functionality.
c34f3f
.sp
c34f3f
\fBmongoimport\fP is single\-threaded and inserts one document at
c34f3f
a time into MongoDB. Custom import tools for data ingestion may have
c34f3f
better performance for specific workloads.
c34f3f
.SH OPTIONS
c34f3f
.sp
c34f3f
Changed in version 3.0.0: \fBmongoimport\fP removed the \fB\-\-dbpath\fP as well as related
c34f3f
\fB\-\-directoryperdb\fP and \fB\-\-journal\fP options. You must use
c34f3f
\fBmongoimport\fP while connected to a \fBmongod\fP instance.
c34f3f
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B mongoimport
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B mongoimport
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-help
c34f3f
Returns information on the options and use of \fBmongoimport\fP\&.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-verbose, \-v
c34f3f
Increases the amount of internal reporting returned on standard output
c34f3f
or in log files. Increase the verbosity with the \fB\-v\fP form by
c34f3f
including the option multiple times, (e.g. \fB\-vvvvv\fP\&.)
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-quiet
c34f3f
Runs the \fBmongoimport\fP in a quiet mode that attempts to limit the amount
c34f3f
of output.
c34f3f
.sp
c34f3f
This option suppresses:
c34f3f
.INDENT 7.0
c34f3f
.IP \(bu 2
c34f3f
output from \fIdatabase commands\fP
c34f3f
.IP \(bu 2
c34f3f
replication activity
c34f3f
.IP \(bu 2
c34f3f
connection accepted events
c34f3f
.IP \(bu 2
c34f3f
connection closed events
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-version
c34f3f
Returns the \fBmongoimport\fP release number.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-host <hostname><:port>, \-h <hostname><:port>
c34f3f
\fIDefault\fP: localhost:27017
c34f3f
.sp
c34f3f
Specifies a resolvable hostname for the \fBmongod\fP to which to
c34f3f
connect. By default, the \fBmongoimport\fP attempts to connect to a MongoDB
c34f3f
instance running on the localhost on port number \fB27017\fP\&.
c34f3f
.sp
c34f3f
To connect to a replica set, specify the
c34f3f
\fBreplSetName\fP and a seed list of set members, as in
c34f3f
the following:
c34f3f
.INDENT 7.0
c34f3f
.INDENT 3.5
c34f3f
.sp
c34f3f
.nf
c34f3f
.ft C
c34f3f
<replSetName>/<hostname1><:port>,<hostname2><:port>,<...>
c34f3f
.ft P
c34f3f
.fi
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.sp
c34f3f
You can always connect directly to a single MongoDB instance by
c34f3f
specifying the host and port number directly.
c34f3f
.sp
c34f3f
Changed in version 3.0.0: If you use IPv6 and use the \fB<address>:<port>\fP format, you must
c34f3f
enclose the portion of an address and port combination in
c34f3f
brackets (e.g. \fB[<address>]\fP).
c34f3f
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-port <port>
c34f3f
\fIDefault\fP: 27017
c34f3f
.sp
c34f3f
Specifies the TCP port on which the MongoDB instance listens for
c34f3f
client connections.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-ipv6
c34f3f
Enables IPv6 support and allows the \fBmongoimport\fP to connect to the
c34f3f
MongoDB instance using an IPv6 network. All MongoDB programs and
c34f3f
processes disable IPv6 support by default.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-ssl
c34f3f
New in version 2.6.
c34f3f
c34f3f
.sp
c34f3f
Enables connection to a \fBmongod\fP or \fBmongos\fP that has
c34f3f
SSL support enabled.
c34f3f
.sp
c34f3f
The default distribution of MongoDB does not contain support for SSL.
c34f3f
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-sslCAFile <filename>
c34f3f
New in version 2.6.
c34f3f
c34f3f
.sp
c34f3f
Specifies the \fB\&.pem\fP file that contains the root certificate chain
c34f3f
from the Certificate Authority. Specify the file name of the
c34f3f
\fB\&.pem\fP file using relative or absolute paths.
c34f3f
.sp
c34f3f
The default distribution of MongoDB does not contain support for SSL.
c34f3f
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
c34f3f
.sp
c34f3f
\fBWARNING:\fP
c34f3f
.INDENT 7.0
c34f3f
.INDENT 3.5
c34f3f
If the \fBmongo\fP shell or any other tool that connects to
c34f3f
\fBmongos\fP or \fBmongod\fP is run without
c34f3f
\fI\-\-sslCAFile\fP, it will not attempt to validate
c34f3f
server certificates. This results in vulnerability to expired
c34f3f
\fBmongod\fP and \fBmongos\fP certificates as well as to foreign
c34f3f
processes posing as valid \fBmongod\fP or \fBmongos\fP
c34f3f
instances. Ensure that you \fIalways\fP specify the CA file against which
c34f3f
server certificates should be validated in cases where intrusion is a
c34f3f
possibility.
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-sslPEMKeyFile <filename>
c34f3f
New in version 2.6.
c34f3f
c34f3f
.sp
c34f3f
Specifies the \fB\&.pem\fP file that contains both the SSL certificate
c34f3f
and key. Specify the file name of the \fB\&.pem\fP file using relative
c34f3f
or absolute paths.
c34f3f
.sp
c34f3f
This option is required when using the \fI\-\-ssl\fP option to connect
c34f3f
to a \fBmongod\fP or \fBmongos\fP that has
c34f3f
\fBCAFile\fP enabled \fIwithout\fP
c34f3f
\fBallowConnectionsWithoutCertificates\fP\&.
c34f3f
.sp
c34f3f
The default distribution of MongoDB does not contain support for SSL.
c34f3f
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-sslPEMKeyPassword <value>
c34f3f
New in version 2.6.
c34f3f
c34f3f
.sp
c34f3f
Specifies the password to de\-crypt the certificate\-key file (i.e.
c34f3f
\fI\-\-sslPEMKeyFile\fP). Use the \fI\-\-sslPEMKeyPassword\fP option only if the
c34f3f
certificate\-key file is encrypted. In all cases, the \fBmongoimport\fP will
c34f3f
redact the password from all logging and reporting output.
c34f3f
.sp
c34f3f
If the private key in the PEM file is encrypted and you do not specify
c34f3f
the \fI\-\-sslPEMKeyPassword\fP option, the \fBmongoimport\fP will prompt for a passphrase. See
c34f3f
\fIssl\-certificate\-password\fP\&.
c34f3f
.sp
c34f3f
The default distribution of MongoDB does not contain support for SSL.
c34f3f
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-sslCRLFile <filename>
c34f3f
New in version 2.6.
c34f3f
c34f3f
.sp
c34f3f
Specifies the \fB\&.pem\fP file that contains the Certificate Revocation
c34f3f
List. Specify the file name of the \fB\&.pem\fP file using relative or
c34f3f
absolute paths.
c34f3f
.sp
c34f3f
The default distribution of MongoDB does not contain support for SSL.
c34f3f
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-sslAllowInvalidCertificates
c34f3f
New in version 2.6.
c34f3f
c34f3f
.sp
c34f3f
Bypasses the validation checks for server certificates and allows
c34f3f
the use of invalid certificates. When using the
c34f3f
\fBallowInvalidCertificates\fP setting, MongoDB logs as a
c34f3f
warning the use of the invalid certificate.
c34f3f
.sp
c34f3f
The default distribution of MongoDB does not contain support for SSL.
c34f3f
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-sslAllowInvalidHostnames
c34f3f
New in version 3.0.
c34f3f
c34f3f
.sp
c34f3f
Disables the validation of the hostnames in SSL certificates. Allows
c34f3f
\fBmongoimport\fP to connect to MongoDB instances if the hostname their
c34f3f
certificates do not match the specified hostname.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-sslFIPSMode
c34f3f
New in version 2.6.
c34f3f
c34f3f
.sp
c34f3f
Directs the \fBmongoimport\fP to use the FIPS mode of the installed OpenSSL
c34f3f
library. Your system must have a FIPS compliant OpenSSL library to use
c34f3f
the \fI\-\-sslFIPSMode\fP option.
c34f3f
.sp
c34f3f
\fBNOTE:\fP
c34f3f
.INDENT 7.0
c34f3f
.INDENT 3.5
c34f3f
FIPS Compatible SSL is
c34f3f
available only in \fI\%MongoDB Enterprise\fP\&. See
c34f3f
http://docs.mongodb.org/manual/tutorial/configure\-fips for more information.
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-username <username>, \-u <username>
c34f3f
Specifies a username with which to authenticate to a MongoDB database
c34f3f
that uses authentication. Use in conjunction with the \fB\-\-password\fP and
c34f3f
\fB\-\-authenticationDatabase\fP options.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-password <password>, \-p <password>
c34f3f
Specifies a password with which to authenticate to a MongoDB database
c34f3f
that uses authentication. Use in conjunction with the \fB\-\-username\fP and
c34f3f
\fB\-\-authenticationDatabase\fP options.
c34f3f
.sp
c34f3f
If you do not specify an argument for \fI\-\-password\fP, \fBmongoimport\fP will
c34f3f
prompt interactively for a password on the console.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-authenticationDatabase <dbname>
c34f3f
New in version 2.4.
c34f3f
c34f3f
.sp
c34f3f
Specifies the database that holds the user\(aqs credentials.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-authenticationMechanism <name>
c34f3f
\fIDefault\fP: MONGODB\-CR
c34f3f
.sp
c34f3f
New in version 2.4.
c34f3f
c34f3f
.sp
c34f3f
Changed in version 2.6: Added support for the \fBPLAIN\fP and \fBMONGODB\-X509\fP authentication
c34f3f
mechanisms.
c34f3f
c34f3f
.sp
c34f3f
Specifies the authentication mechanism the \fBmongoimport\fP instance uses to
c34f3f
authenticate to the \fBmongod\fP or \fBmongos\fP\&.
c34f3f
.TS
c34f3f
center;
c34f3f
|l|l|.
c34f3f
_
c34f3f
T{
c34f3f
Value
c34f3f
T}	T{
c34f3f
Description
c34f3f
T}
c34f3f
_
c34f3f
T{
c34f3f
MONGODB\-CR
c34f3f
T}	T{
c34f3f
MongoDB challenge/response authentication.
c34f3f
T}
c34f3f
_
c34f3f
T{
c34f3f
MONGODB\-X509
c34f3f
T}	T{
c34f3f
MongoDB SSL certificate authentication.
c34f3f
T}
c34f3f
_
c34f3f
T{
c34f3f
PLAIN
c34f3f
T}	T{
c34f3f
External authentication using LDAP. You can also use \fBPLAIN\fP
c34f3f
for authenticating in\-database users. \fBPLAIN\fP transmits
c34f3f
passwords in plain text. This mechanism is available only in
c34f3f
\fI\%MongoDB Enterprise\fP\&.
c34f3f
T}
c34f3f
_
c34f3f
T{
c34f3f
GSSAPI
c34f3f
T}	T{
c34f3f
External authentication using Kerberos. This mechanism is
c34f3f
available only in \fI\%MongoDB Enterprise\fP\&.
c34f3f
T}
c34f3f
_
c34f3f
.TE
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-gssapiServiceName
c34f3f
New in version 2.6.
c34f3f
c34f3f
.sp
c34f3f
Specify the name of the service using \fBGSSAPI/Kerberos\fP\&. Only required if the service does not use the
c34f3f
default name of \fBmongodb\fP\&.
c34f3f
.sp
c34f3f
This option is available only in MongoDB Enterprise.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-gssapiHostName
c34f3f
New in version 2.6.
c34f3f
c34f3f
.sp
c34f3f
Specify the hostname of a service using \fBGSSAPI/Kerberos\fP\&. \fIOnly\fP required if the hostname of a machine does
c34f3f
not match the hostname resolved by DNS.
c34f3f
.sp
c34f3f
This option is available only in MongoDB Enterprise.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-db <database>, \-d <database>
c34f3f
Specifies the name of the database on which to run the \fBmongoimport\fP\&.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-collection <collection>, \-c <collection>
c34f3f
Specifies the collection to import.
c34f3f
.sp
c34f3f
New in version 2.6: If you do not specify \fI\-\-collection\fP,
c34f3f
\fBmongoimport\fP takes the collection name from the input
c34f3f
filename. MongoDB omits the extension of the file from the
c34f3f
collection name, if the input file has an extension.
c34f3f
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-fields <field1[,field2]>, \-f <field1[,field2]>
c34f3f
Specify a comma separated list of field names when importing \fIcsv\fP
c34f3f
or \fItsv\fP files that do not have field names in the first (i.e.
c34f3f
header) line of the file.
c34f3f
.sp
c34f3f
If you attempt to include \fI\%\-\-fields\fP when importing JSON data,
c34f3f
\fBmongoimport\fP will return an error. \fI\%\-\-fields\fP is only for \fIcsv\fP
c34f3f
or \fItsv\fP imports.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-fieldFile <filename>
c34f3f
As an alternative to \fI\%\-\-fields\fP, the \fI\%\-\-fieldFile\fP
c34f3f
option allows you to specify a file that holds a list of field names if
c34f3f
your \fIcsv\fP or \fItsv\fP file does not include field names in the
c34f3f
first line of the file (i.e. header). Place one field per line.
c34f3f
.sp
c34f3f
If you attempt to include \fI\%\-\-fieldFile\fP when importing JSON data,
c34f3f
\fBmongoimport\fP will return an error. \fI\%\-\-fieldFile\fP is only for \fIcsv\fP
c34f3f
or \fItsv\fP imports.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-ignoreBlanks
c34f3f
Ignores empty fields in \fIcsv\fP and \fItsv\fP exports. If not
c34f3f
specified, \fBmongoimport\fP creates fields without values in
c34f3f
imported documents.
c34f3f
.sp
c34f3f
If you attempt to include \fI\%\-\-ignoreBlanks\fP when importing JSON data,
c34f3f
\fBmongoimport\fP will return an error. \fI\%\-\-ignoreBlanks\fP is only for \fIcsv\fP
c34f3f
or \fItsv\fP imports.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-type <json|csv|tsv>
c34f3f
Specifies the file type to import. The default format is \fIJSON\fP,
c34f3f
but it\(aqs possible to import \fIcsv\fP and \fItsv\fP files.
c34f3f
.sp
c34f3f
The \fBcsv\fP parser accepts that data that complies with RFC
c34f3f
\fI\%RFC 4180\fP\&. As a result, backslashes are \fInot\fP a valid escape
c34f3f
character. If you use double\-quotes to enclose fields in the CSV
c34f3f
data, you must escape internal double\-quote marks by prepending
c34f3f
another double\-quote.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-file <filename>
c34f3f
Specifies the location and name of a file containing the data to import.
c34f3f
If you do not specify a file, \fBmongoimport\fP reads data from
c34f3f
standard input (e.g. "stdin").
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-drop
c34f3f
Modifies the import process so that the target instance drops
c34f3f
the collection before importing the data from the input.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-headerline
c34f3f
If using \fI\-\-type csv\fP or \fI\-\-type
c34f3f
tsv\fP, uses the first line as field names.
c34f3f
Otherwise, \fBmongoimport\fP will import the first line as a
c34f3f
distinct document.
c34f3f
.sp
c34f3f
If you attempt to include \fI\%\-\-headerline\fP when importing JSON data,
c34f3f
\fBmongoimport\fP will return an error. \fI\%\-\-headerline\fP is only for \fIcsv\fP
c34f3f
or \fItsv\fP imports.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-upsert
c34f3f
Modifies the import process to update existing objects in the
c34f3f
database if they match an imported object, while inserting all
c34f3f
other objects.
c34f3f
.sp
c34f3f
If you do not specify a field or fields using the
c34f3f
\fI\%\-\-upsertFields\fP \fBmongoimport\fP will upsert on the
c34f3f
basis of the \fB_id\fP field.
c34f3f
.INDENT 7.0
c34f3f
.TP
c34f3f
.B \&..versionchanged:: 3.0.0
c34f3f
\fI\%\-\-upsert\fP is no longer needed when specifying upserts. Use
c34f3f
\fI\%\-\-upsertFields\fP, which produces the same behavior.
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-upsertFields <field1[,field2]>
c34f3f
Specifies a list of fields for the query portion of the
c34f3f
\fIupsert\fP\&. Use this option if the \fB_id\fP fields in the
c34f3f
existing documents don\(aqt match the field in the document, but
c34f3f
another field or field combination can uniquely identify
c34f3f
documents as a basis for performing upsert operations.
c34f3f
.INDENT 7.0
c34f3f
.TP
c34f3f
.B \&..versionchanged:: 3.0.0
c34f3f
Modifies the import process to update existing objects in the
c34f3f
database if they match based on the specified fields, while
c34f3f
inserting all other objects.
c34f3f
.sp
c34f3f
If you do not specify a field, \fI\%\-\-upsertFields\fP will upsert on the basis of
c34f3f
the \fB_id\fP field.
c34f3f
.UNINDENT
c34f3f
.sp
c34f3f
To ensure adequate performance, indexes should exist for this
c34f3f
field or fields.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-stopOnError
c34f3f
New in version 2.2.
c34f3f
c34f3f
.sp
c34f3f
Forces \fBmongoimport\fP to halt the import operation at the
c34f3f
first error rather than continuing the operation despite errors.
c34f3f
.sp
c34f3f
Changed in version 3.0.0: \fI\%\-\-stopOnError\fP interrupts the import operation when \fBmongoimport\fP encounters
c34f3f
an insert or upsert error. Other error types will not stop
c34f3f
the import.
c34f3f
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-jsonArray
c34f3f
Accepts the import of data expressed with multiple MongoDB documents
c34f3f
within a single \fIJSON\fP array. Limited to
c34f3f
imports of 16 MB or smaller.
c34f3f
.sp
c34f3f
Use \fI\%\-\-jsonArray\fP in conjunction with \fImongoexport \-\-jsonArray\fP\&.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-maintainInsertionOrder
c34f3f
\fIDefault\fP: False
c34f3f
.sp
c34f3f
If specified, \fBmongoimport\fP inserts the documents in the order of
c34f3f
their appearance in the input source, otherwise \fBmongoimport\fP may
c34f3f
perform the insertions in an arbitrary order.
c34f3f
.UNINDENT
c34f3f
.INDENT 0.0
c34f3f
.TP
c34f3f
.B \-\-writeConcern <document>
c34f3f
\fIDefault\fP: majority
c34f3f
.sp
c34f3f
Specifies the \fIwrite concern\fP for each write operation that \fBmongoimport\fP
c34f3f
writes to the target database.
c34f3f
.sp
c34f3f
Specify the write concern as a document with \fIw options\fP\&.
c34f3f
.UNINDENT
c34f3f
.SH USE
c34f3f
.sp
c34f3f
In this example, \fBmongoimport\fP imports the \fIcsv\fP
c34f3f
formatted data in the \fB/opt/backups/contacts.csv\fP into the
c34f3f
collection \fBcontacts\fP in the \fBusers\fP database on the MongoDB
c34f3f
instance running on the localhost port numbered
c34f3f
\fB27017\fP\&. \fBmongoimport\fP determines the name of files using
c34f3f
the first line in the CSV file, because of the \fI\-\-headerline\fP:
c34f3f
.INDENT 0.0
c34f3f
.INDENT 3.5
c34f3f
.sp
c34f3f
.nf
c34f3f
.ft C
c34f3f
mongoimport \-\-db users \-\-collection contacts \-\-type csv \-\-headerline \-\-file /opt/backups/contacts.csv
c34f3f
.ft P
c34f3f
.fi
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.sp
c34f3f
Since \fBmongoimport\fP uses the input file name, without the
c34f3f
extension, as the collection name if \fB\-c\fP or \fB\-\-collection\fP is
c34f3f
unspecified. The following example is equivalent:
c34f3f
.INDENT 0.0
c34f3f
.INDENT 3.5
c34f3f
.sp
c34f3f
.nf
c34f3f
.ft C
c34f3f
mongoimport \-\-db users \-\-type csv \-\-headerline \-\-file /opt/backups/contacts.csv
c34f3f
.ft P
c34f3f
.fi
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.sp
c34f3f
In the following example, \fBmongoimport\fP imports the data in
c34f3f
the \fIJSON\fP formatted file \fBcontacts.json\fP into the collection
c34f3f
\fBcontacts\fP on the MongoDB instance running on the localhost port
c34f3f
number 27017.
c34f3f
.INDENT 0.0
c34f3f
.INDENT 3.5
c34f3f
.sp
c34f3f
.nf
c34f3f
.ft C
c34f3f
mongoimport \-\-db users \-\-collection contacts \-\-file contacts.json
c34f3f
.ft P
c34f3f
.fi
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.sp
c34f3f
In the next example, \fBmongoimport\fP imports data from the
c34f3f
file \fB/opt/backups/mdb1\-examplenet.json\fP into the collection
c34f3f
\fBcontacts\fP within the database \fBmarketing\fP on a remote MongoDB
c34f3f
database. This \fBmongoimport\fP accesses the \fBmongod\fP
c34f3f
instance running on the host \fBmongodb1.example.net\fP over port
c34f3f
\fB37017\fP, which requires the username \fBuser\fP and the password
c34f3f
\fBpass\fP\&.
c34f3f
.INDENT 0.0
c34f3f
.INDENT 3.5
c34f3f
.sp
c34f3f
.nf
c34f3f
.ft C
c34f3f
mongoimport \-\-host mongodb1.example.net \-\-port 37017 \-\-username user \-\-password pass \-\-collection contacts \-\-db marketing \-\-file /opt/backups/mdb1\-examplenet.json
c34f3f
.ft P
c34f3f
.fi
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.SH TYPE FIDELITY
c34f3f
.sp
c34f3f
\fBWARNING:\fP
c34f3f
.INDENT 0.0
c34f3f
.INDENT 3.5
c34f3f
\fBmongoimport\fP and \fBmongoexport\fP do not reliably
c34f3f
preserve all rich \fIBSON\fP data types because \fIJSON\fP can
c34f3f
only represent a subset of the types supported by BSON. As a result,
c34f3f
data exported or imported with these tools may lose some measure of
c34f3f
fidelity. See the \fBExtended JSON\fP
c34f3f
reference for more information.
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.sp
c34f3f
JSON can only represent a subset of the types supported by BSON. To
c34f3f
preserve type information, \fBmongoimport\fP accepts \fBstrict
c34f3f
mode representation\fP for certain
c34f3f
types.
c34f3f
.sp
c34f3f
For example, to preserve type information for BSON types
c34f3f
\fBdata_date\fP and \fBdata_numberlong\fP during
c34f3f
\fBmongoimport\fP, the data should be in strict mode
c34f3f
representation, as in the following:
c34f3f
.INDENT 0.0
c34f3f
.INDENT 3.5
c34f3f
.sp
c34f3f
.nf
c34f3f
.ft C
c34f3f
{ "_id" : 1, "volume" : { "$numberLong" : "2980000" }, "date" : { "$date" : "2014\-03\-13T13:47:42.483\-0400" } }
c34f3f
.ft P
c34f3f
.fi
c34f3f
.UNINDENT
c34f3f
.UNINDENT
c34f3f
.sp
c34f3f
For the \fBdata_numberlong\fP type, \fBmongoimport\fP
c34f3f
converts into a float during the import.
c34f3f
.sp
c34f3f
See http://docs.mongodb.org/manual/reference/mongodb\-extended\-json for a complete list of
c34f3f
these types and the representations used.
c34f3f
.SH AUTHOR
c34f3f
MongoDB Documentation Project
c34f3f
.SH COPYRIGHT
c34f3f
2011-2015
c34f3f
.\" Generated by docutils manpage writer.
c34f3f
.