Blame SOURCES/mongoimport.1

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