1
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
2
.TH MONGOIMPORT "1" "January 2010" "10gen" "Mongo Database"
4
mongoimport \- the Mongo import tool
6
\fBmongoimport [\fIOPTIONS\fR]\fR
10
is a tool to import a MongoDB collection from JSON, CSV, or TSV. The query can be filtered or a list of fields to input can be given.
13
.\".B mongoimport -d test -c test1 --csv -f "name,num"
14
.\"import documents from test.test1 in CSV format
1
.TH "MONGOIMPORT" "1" "March 14, 2013" "2.2.3" "mongodb-manual"
5
.nr rst2man-indent-level 0
9
level \\n[rst2man-indent-level]
10
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
17
.\" .rstReportMargin pre:
19
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
20
. nr rst2man-indent-level +1
21
.\" .rstReportMargin post:
25
.\" indent \\n[an-margin]
26
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
27
.nr rst2man-indent-level -1
28
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
29
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
31
.\" Man page generated from reStructuredText.
35
The \fI\%mongoimport\fP tool provides a route to import content from a
36
JSON, CSV, or TSV export created by \fBmongoexport\fP, or
37
potentially, another third\-party export tool. See the
38
"\fB/administration/import\-export\fP" document for a more in depth
39
usage overview, and the "\fBmongoexport\fP" document for more
40
information regarding \fBmongoexport\fP, which
41
provides the inverse "importing" capability.
43
Do not use \fI\%mongoimport\fP and \fBmongoexport\fP for
44
full instance, production backups because they will not reliably capture data type
45
information. Use \fBmongodump\fP and \fBmongorestore\fP as
46
described in "\fB/administration/backups\fP" for this kind of
18
show usage information
57
Returns a basic help and usage text.
62
Increases the amount of internal reporting returned on the command
63
line. Increase the verbosity with the \fB\-v\fP form by including
64
the option multiple times, (e.g. \fB\-vvvvv\fP.)
21
show version information
24
be more verbose (include multiple times for more verbosity
28
server to connect to (default HOST=localhost)
31
server port. Can also use \-\-host hostname:port
69
Returns the version of the \fI\%mongoimport\fP program.
73
.B \-\-host <hostname><:port>, \-h
74
Specifies a resolvable hostname for the \fBmongod\fP to which
75
you want to restore the database. By default \fI\%mongoimport\fP
76
will attempt to connect to a MongoDB process ruining on the
77
localhost port numbered \fB27017\fP.
79
Optionally, specify a port number to connect a MongoDB instance
80
running on a port other than \fB27017\fP.
82
To connect to a replica set, use the \fI\%--host\fP argument with a
83
setname, followed by a slash and a comma\-separated list of host and
84
port names. \fI\%mongoimport\fP will, given the seed of at least
85
one connected set member, connect to primary node of that set. This
86
option would resemble:
90
\-\-host repl0/mongo0.example.net,mongo0.example.net:27018,mongo1.example.net,mongo2.example.net
94
You can always connect directly to a single MongoDB instance by
95
specifying the host and port number directly.
100
Specifies the port number, if the MongoDB instance is not running on
101
the standard port. (i.e. \fB27017\fP) You may also specify a port
102
number using the \fI\%mongoimport --host\fP command.
34
enable IPv6 support (disabled by default)
36
.B \-u|\-\-username USERNAME
37
specify user to log in as
39
.B \-p|\-\-password PASSWORD
40
specify password of user
43
directly access mongod data files in this path, instead of connecting to a mongod instance
107
Enables IPv6 support that allows \fI\%mongoimport\fP to connect
108
to the MongoDB instance using an IPv6 network. All MongoDB programs
109
and processes, including \fI\%mongoimport\fP, disable IPv6
115
New in version 2.4: MongoDB added support for SSL connections to \fBmongod\fP
116
instances in mongoimport.
118
SSL support in mongoimport is not compiled into the default
119
distribution of MongoDB. See \fB/administration/ssl\fP for more
120
information on SSL and MongoDB.
122
Additionally, mongoimport does not support connections to
123
\fBmongod\fP instances that require client certificate
127
Allows \fI\%mongoimport\fP to connect to \fBmongod\fP
128
instance over an SSL connection.
132
.B \-\-username <username>, \-u <username>
133
Specifies a username to authenticate to the MongoDB instance, if your
134
database requires authentication. Use in conjunction with the
135
\fI\%mongoimport --password\fP option to supply a password.
139
.B \-\-password <password>, \-p <password>
140
Specifies a password to authenticate to the MongoDB instance. Use
141
in conjunction with the \fI\%mongoimport --username\fP option to
144
If you specify a \fI\%--username\fP
145
without the \fI\%--password\fP option, \fI\%mongoimport\fP
146
will prompt for a password interactively.
150
.B \-\-authenticationDatabase <dbname>
153
Specifies the database that holds the user\(aqs (e.g
154
\fI\%--username\fP) credentials.
156
By default, \fI\%mongoimport\fP assumes that the database specified to the
157
\fI\%--db\fP argument holds the user\(aqs credentials, unless you
158
specify \fI\%--authenticationDatabase\fP.
160
See \fBuserSource\fP,
161
\fB/reference/privilege\-documents\fP and
162
\fB/reference/user\-privileges\fP for more information about
163
delegated authentication in MongoDB.
167
.B \-\-authenticationMechanism <name>
170
Specifies the authentication mechanism. By default, the
171
authentication mechanism is \fBMONGODB\-CR\fP, which is the MongoDB
172
challenge/response authentication mechanism. In the MongoDB Subscriber Edition,
173
\fI\%mongoimport\fP also includes support for \fBGSSAPI\fP to handle
174
Kerberos authentication.
176
See \fB/tutorial/control\-access\-to\-mongodb\-with\-kerberos\-authentication\fP
177
for more information about Kerberos authentication.
182
Specifies the directory of the MongoDB data files. If used, the
183
\fI\%--dbpath\fP option enables
184
\fI\%mongoimport\fP to attach directly to local data files and
185
insert the data without the \fBmongod\fP. To run with
186
\fB\-\-dbpath\fP, \fI\%mongoimport\fP needs to lock access to the
187
data directory: as a result, no \fBmongod\fP can access the
188
same path while the process runs.
45
192
.B \-\-directoryperdb
46
if dbpath specified, each db is in a separate directory
48
.B \-d, \-\-db DATABASE
51
.B \-c, \-\-c COLLECTION
55
directly access mongod data files in this path,
56
instead of connecting to a mongod instance
59
be more verbose (include multiple times for more
60
verbosity e.g. \fB\-vvvvv\fR)
62
.B \-f, \-\-fields NAMES
63
comma separated list of field names e.g. \fB\-f\fR name,age
66
file with fields names \- 1 per line
69
load a json array, not one item per line. Currently limited to 4MB.
193
Use the \fI\%--directoryperdb\fP in conjunction with the
194
corresponding option to \fBmongod\fP, which allows
195
\fI\%mongoimport\fP to import data into MongoDB instances that
196
have every database\(aqs files saved in discrete directories on the
197
disk. This option is only relevant when specifying the
198
\fI\%--dbpath\fP option.
203
Allows \fBmongoexport\fP write to the durability
204
\fIjournal\fP to ensure that the data files will remain in a
205
consistent state during the write process. This option is only
206
relevant when specifying the \fI\%--dbpath\fP option.
210
.B \-\-db <db>, \-d <db>
211
Use the \fI\%--db\fP option to specify a database for
212
\fI\%mongoimport\fP to restore data. If you do not specify a
213
\fB<db>\fP, \fI\%mongoimport\fP creates new databases that
214
correspond to the databases where data originated and data may be
215
overwritten. Use this option to restore data into a MongoDB
216
instance that already has data, or to restore only some data in the
221
.B \-\-collection <collection>, \-c <collection>
222
Use the \fI\%--collection\fP option to specify a collection for
223
\fBmongorestore\fP to restore. If you do not specify a
224
\fB<collection>\fP, \fI\%mongoimport\fP imports all collections
225
created. Existing data may be overwritten. Use this option to
226
restore data into a MongoDB instance that already has data, or to
227
restore only some data in the specified imported data set.
231
.B \-\-fields <field1<,filed2>>, \-f <field1[,filed2]>
232
Specify a comma seperatedlist of field names when importing
233
\fIcsv\fP or \fItsv\fP files that do not have field names in
234
the first (i.e. header) line of the file.
238
.B \-\-fieldFile <filename>
239
As an alternative to \fI\%--fields\fP the \fI\%--fieldFile\fP
240
option allows you to specify a file (e.g. \fB<file>\(ga\fP) to that
241
holds a list of field names if your \fIcsv\fP or \fItsv\fP
242
file does not include field names in the first (i.e. header) line
243
of the file. Place one field per line.
71
247
.B \-\-ignoreBlanks
72
if given, empty fields in csv and tsv will be ignored
75
type of file to import. default: json (json,csv,tsv)
78
file to import from; if not specified stdin is used
248
In \fIcsv\fP and \fItsv\fP exports, ignore empty fields. If not
249
specified, \fI\%mongoimport\fP creates fields without values in
254
.B \-\-type <json|csv|tsv>
255
Declare the type of export format to import. The default format is
256
\fIJSON\fP, but it\(aqs possible to import \fIcsv\fP and
261
.B \-\-file <filename>
262
Specify the location of a file containing the data to
263
import. \fI\%mongoimport\fP will read data from standard input
264
(e.g. "stdin.") if you do not specify a file.
269
Modifies the importation procedure so that the target instance
270
drops every collection before restoring the collection from the
84
CSV,TSV only \- use first line as headers
276
If using "\fI\%--type csv\fP" or
277
"\fI\%--type tsv\fP," use the first line as
278
field names. Otherwise, \fI\%mongoimport\fP will import the first
279
line as a distinct document.
87
insert or update objects that already exist
284
Modifies the import process to update existing objects in the
285
database if they match an imported object, while inserting all
288
If you do not specify a field or fields using the
289
\fI\%--upsertFields\fP \fI\%mongoimport\fP will upsert on the
290
basis of the \fB_id\fP field.
89
.B \-\-upsertFields ARG
90
comma-separated fields for the query part of the upsert. You should
91
make sure this is indexed
294
.B \-\-upsertFields <field1[,field2]>
295
Specifies a list of fields for the query portion of the
296
\fIupsert\fP. Use this option if the \fB_id\fP fields in the
297
existing documents don\(aqt match the field in the document, but
298
another field or field combination can uniquely identify
299
documents as a basis for performing upsert operations.
301
To ensure adequate performance, indexes should exist for this
93
306
.B \-\-stopOnError
94
stop importing at first error rather than continuing
309
Forces \fI\%mongoimport\fP to halt the import operation at the
310
first error rather than continuing the operation despite errors.
97
load a json array, not one item per line. Currently limited to 16MB.
100
Copyright 2007\-2011 10gen
102
For more information, please refer to the MongoDB wiki, available at http://www.mongodb.org.
315
Changed in version 2.2: The limit on document size increased from 4MB to 16MB.
317
Accept import of data expressed with multiple MongoDB document
318
within a single \fIJSON\fP array.
320
Use in conjunction with \fImongoexport \-\-jsonArray\fP to
321
import data written as a single \fIJSON\fP array. Limited to
322
imports of 16 MB or smaller.
326
In this example, \fI\%mongoimport\fP imports the \fIcsv\fP
327
formatted data in the \fB/opt/backups/contacts.csv\fP into the
328
collection \fBcontacts\fP in the \fBusers\fP database on the MongoDB
329
instance running on the localhost port numbered \fB27017\fP.
333
mongoimport \-\-db users \-\-collection contacts \-\-type csv \-\-file /opt/backups/contacts.csv
337
In the following example, \fI\%mongoimport\fP imports the data in
338
the \fIJSON\fP formatted file \fBcontacts.json\fP into the collection
339
\fBcontacts\fP on the MongoDB instance running on the localhost port
340
number 27017. Journaling is explicitly enabled.
344
mongoimport \-\-collection contacts \-\-file contacts.json \-\-journal
348
In the next example, \fI\%mongoimport\fP takes data passed to it on
349
standard input (i.e. with a \fB|\fP pipe.) and imports it into the
350
collection \fBcontacts\fP in the \fBsales\fP database is the
351
MongoDB datafiles located at \fB/srv/mongodb/\fP. if the import process
352
encounters an error, the \fI\%mongoimport\fP will halt because of
353
the \fI\%--stopOnError\fP option.
357
mongoimport \-\-db sales \-\-collection contacts \-\-stopOnError \-\-dbpath /srv/mongodb/
361
In the final example, \fI\%mongoimport\fP imports data from the
362
file \fB/opt/backups/mdb1\-examplenet.json\fP into the collection
363
\fBcontacts\fP within the database \fBmarketing\fP on a remote MongoDB
364
database. This \fI\%mongoimport\fP accesses the \fBmongod\fP
365
instance running on the host \fBmongodb1.example.net\fP over port
366
\fB37017\fP, which requires the username \fBuser\fP and the password
371
mongoimport \-\-host mongodb1.example.net \-\-port 37017 \-\-username user \-\-password pass \-\-collection contacts \-\-db marketing \-\-file /opt/backups/mdb1\-examplenet.json
375
MongoDB Documentation Project
377
2011-2013, 10gen, Inc.
378
.\" Generated by docutils manpage writer.