1MONGOFILES(1) mongodb-manual MONGOFILES(1)
2
3
4
6 mongofiles - MongoDB GridFS Utility
7
9 The mongofiles utility makes it possible to manipulate files stored in
10 your MongoDB instance in GridFS objects from the command line. It is
11 particularly useful as it provides an interface between objects stored
12 in your file system and GridFS.
13
14 All mongofiles commands have the following form:
15
16 mongofiles <options> <commands> <filename>
17
18 The components of the mongofiles command are:
19
20 1. Options. You may use one or more of these options to control the
21 behavior of mongofiles.
22
23 2. Commands. Use one of these commands to determine the action of mon‐
24 gofiles.
25
26 3. A filename which is either: the name of a file on your local's file
27 system, or a GridFS object.
28
29 mongofiles, like mongodump, mongoexport, mongoimport, and mongorestore,
30 can access data stored in a MongoDB data directory without requiring a
31 running mongod instance, if no other mongod is running.
32
33 IMPORTANT:
34 For replica sets, mongofiles can only read from the set's 'primary.
35
37 Changed in version 3.0.0: mongofiles removed the --dbpath as well as
38 related --directoryperdb and --journal options. You must use mongofiles
39 while connected to a mongod instance.
40
41
42 mongofiles
43
44 --help Returns information on the options and use of mongofiles.
45
46 --verbose, -v
47 Increases the amount of internal reporting returned on standard
48 output or in log files. Increase the verbosity with the -v form
49 by including the option multiple times, (e.g. -vvvvv.)
50
51 --quiet
52 Runs the mongofiles in a quiet mode that attempts to limit the
53 amount of output.
54
55 This option suppresses:
56
57 · output from database commands
58
59 · replication activity
60
61 · connection accepted events
62
63 · connection closed events
64
65 --version
66 Returns the mongofiles release number.
67
68 --host <hostname><:port>
69 Specifies a resolvable hostname for the mongod that holds your
70 GridFS system. By default mongofiles attempts to connect to a
71 MongoDB process running on the localhost port number 27017.
72
73 Optionally, specify a port number to connect a MongoDB instance
74 running on a port other than 27017.
75
76 --port <port>
77 Default: 27017
78
79 Specifies the TCP port on which the MongoDB instance listens for
80 client connections.
81
82 --ipv6 Enables IPv6 support and allows the mongofiles to connect to the
83 MongoDB instance using an IPv6 network. All MongoDB programs and
84 processes disable IPv6 support by default.
85
86 --ssl New in version 2.6.
87
88
89 Enables connection to a mongod or mongos that has SSL support
90 enabled.
91
92 The default distribution of MongoDB does not contain support for
93 SSL. For more information on MongoDB and SSL, see
94 http://docs.mongodb.org/manual/tutorial/configure-ssl.
95
96 --sslCAFile <filename>
97 New in version 2.6.
98
99
100 Specifies the .pem file that contains the root certificate chain
101 from the Certificate Authority. Specify the file name of the
102 .pem file using relative or absolute paths.
103
104 The default distribution of MongoDB does not contain support for
105 SSL. For more information on MongoDB and SSL, see
106 http://docs.mongodb.org/manual/tutorial/configure-ssl.
107
108 WARNING:
109 If the mongo shell or any other tool that connects to mongos
110 or mongod is run without --sslCAFile, it will not attempt to
111 validate server certificates. This results in vulnerability
112 to expired mongod and mongos certificates as well as to for‐
113 eign processes posing as valid mongod or mongos instances.
114 Ensure that you always specify the CA file against which
115 server certificates should be validated in cases where intru‐
116 sion is a possibility.
117
118 --sslPEMKeyFile <filename>
119 New in version 2.6.
120
121
122 Specifies the .pem file that contains both the SSL certificate
123 and key. Specify the file name of the .pem file using relative
124 or absolute paths.
125
126 This option is required when using the --ssl option to connect
127 to a mongod or mongos that has CAFile enabled without allowCon‐
128 nectionsWithoutCertificates.
129
130 The default distribution of MongoDB does not contain support for
131 SSL. For more information on MongoDB and SSL, see
132 http://docs.mongodb.org/manual/tutorial/configure-ssl.
133
134 --sslPEMKeyPassword <value>
135 New in version 2.6.
136
137
138 Specifies the password to de-crypt the certificate-key file
139 (i.e. --sslPEMKeyFile). Use the --sslPEMKeyPassword option only
140 if the certificate-key file is encrypted. In all cases, the mon‐
141 gofiles will redact the password from all logging and reporting
142 output.
143
144 If the private key in the PEM file is encrypted and you do not
145 specify the --sslPEMKeyPassword option, the mongofiles will
146 prompt for a passphrase. See ssl-certificate-password.
147
148 The default distribution of MongoDB does not contain support for
149 SSL. For more information on MongoDB and SSL, see
150 http://docs.mongodb.org/manual/tutorial/configure-ssl.
151
152 --sslCRLFile <filename>
153 New in version 2.6.
154
155
156 Specifies the .pem file that contains the Certificate Revocation
157 List. Specify the file name of the .pem file using relative or
158 absolute paths.
159
160 The default distribution of MongoDB does not contain support for
161 SSL. For more information on MongoDB and SSL, see
162 http://docs.mongodb.org/manual/tutorial/configure-ssl.
163
164 --sslAllowInvalidCertificates
165 New in version 2.6.
166
167
168 Bypasses the validation checks for server certificates and
169 allows the use of invalid certificates. When using the allowIn‐
170 validCertificates setting, MongoDB logs as a warning the use of
171 the invalid certificate.
172
173 The default distribution of MongoDB does not contain support for
174 SSL. For more information on MongoDB and SSL, see
175 http://docs.mongodb.org/manual/tutorial/configure-ssl.
176
177 --sslAllowInvalidHostnames
178 New in version 3.0.
179
180
181 Disables the validation of the hostnames in SSL certificates.
182 Allows mongofiles to connect to MongoDB instances if the host‐
183 name their certificates do not match the specified hostname.
184
185 --sslFIPSMode
186 New in version 2.6.
187
188
189 Directs the mongofiles to use the FIPS mode of the installed
190 OpenSSL library. Your system must have a FIPS compliant OpenSSL
191 library to use the --sslFIPSMode option.
192
193 NOTE:
194 FIPS Compatible SSL is available only in MongoDB Enterprise.
195 See http://docs.mongodb.org/manual/tutorial/configure-fips
196 for more information.
197
198 --username <username>, -u <username>
199 Specifies a username with which to authenticate to a MongoDB
200 database that uses authentication. Use in conjunction with the
201 --password and --authenticationDatabase options.
202
203 --password <password>, -p <password>
204 Specifies a password with which to authenticate to a MongoDB
205 database that uses authentication. Use in conjunction with the
206 --username and --authenticationDatabase options.
207
208 If you do not specify an argument for --password, mongofiles
209 will prompt interactively for a password on the console.
210
211 --authenticationDatabase <dbname>
212 New in version 2.4.
213
214
215 Specifies the database that holds the user's credentials.
216
217 --authenticationMechanism <name>
218 Default: MONGODB-CR
219
220 New in version 2.4.
221
222
223 Changed in version 2.6: Added support for the PLAIN and MON‐
224 GODB-X509 authentication mechanisms.
225
226
227 Specifies the authentication mechanism the mongofiles instance
228 uses to authenticate to the mongod or mongos.
229
230 ┌─────────────┬────────────────────────────┐
231 │Value │ Description │
232 ├─────────────┼────────────────────────────┤
233 │MONGODB-CR │ MongoDB challenge/response │
234 │ │ authentication. │
235 ├─────────────┼────────────────────────────┤
236 │MONGODB-X509 │ MongoDB SSL certificate │
237 │ │ authentication. │
238 ├─────────────┼────────────────────────────┤
239 │PLAIN │ External authentication │
240 │ │ using LDAP. You can also │
241 │ │ use PLAIN for authenticat‐ │
242 │ │ ing in-database users. │
243 │ │ PLAIN transmits passwords │
244 │ │ in plain text. This mecha‐ │
245 │ │ nism is available only in │
246 │ │ MongoDB Enterprise. │
247 ├─────────────┼────────────────────────────┤
248 │GSSAPI │ External authentication │
249 │ │ using Kerberos. This mech‐ │
250 │ │ anism is available only in │
251 │ │ MongoDB Enterprise. │
252 └─────────────┴────────────────────────────┘
253
254 --gssapiServiceName
255 New in version 2.6.
256
257
258 Specify the name of the service using GSSAPI/Kerberos. Only
259 required if the service does not use the default name of mon‐
260 godb.
261
262 This option is available only in MongoDB Enterprise.
263
264 --gssapiHostName
265 New in version 2.6.
266
267
268 Specify the hostname of a service using GSSAPI/Kerberos. Only
269 required if the hostname of a machine does not match the host‐
270 name resolved by DNS.
271
272 This option is available only in MongoDB Enterprise.
273
274 --db <database>, -d <database>
275 Specifies the name of the database on which to run the mon‐
276 gofiles.
277
278 --collection <collection>, -c <collection>
279 This option has no use in this context and a future release may
280 remove it. See SERVER-4931 for more information.
281
282 --local <filename>, -l <filename>
283 Specifies the local filesystem name of a file for get and put
284 operations.
285
286 In the mongofiles put and mongofiles get commands, the required
287 <filename> modifier refers to the name the object will have in
288 GridFS. mongofiles assumes that this reflects the file's name on
289 the local file system. This setting overrides this default.
290
291 --type <MIME>
292 Provides the ability to specify a MIME type to describe the file
293 inserted into GridFS storage. mongofiles omits this option in
294 the default operation.
295
296 Use only with mongofiles put operations.
297
298 --replace, -r
299 Alters the behavior of mongofiles put to replace existing GridFS
300 objects with the specified local file, rather than adding an
301 additional object with the same name.
302
303 In the default operation, files will not be overwritten by a
304 mongofiles put option.
305
306 --prefix string
307 Default: fs
308
309 GridFS prefix to use.
310
311 --writeConcern <document>
312 Default: majority
313
314 Specifies the write concern for each write operation that mon‐
315 gofiles writes to the target database.
316
317 Specify the write concern as a document with w options.
318
320 list <prefix>
321 Lists the files in the GridFS store. The characters specified
322 after list (e.g. <prefix>) optionally limit the list of returned
323 items to files that begin with that string of characters.
324
325 search <string>
326 Lists the files in the GridFS store with names that match any
327 portion of <string>.
328
329 put <filename>
330 Copy the specified file from the local file system into GridFS
331 storage.
332
333 Here, <filename> refers to the name the object will have in
334 GridFS, and mongofiles assumes that this reflects the name the
335 file has on the local file system. If the local filename is dif‐
336 ferent use the mongofiles --local option.
337
338 get <filename>
339 Copy the specified file from GridFS storage to the local file
340 system.
341
342 Here, <filename> refers to the name the object will have in
343 GridFS, and mongofiles assumes that this reflects the name the
344 file has on the local file system. If the local filename is dif‐
345 ferent use the mongofiles --local option.
346
347 delete <filename>
348 Delete the specified file from GridFS storage.
349
351 To return a list of all files in a GridFS collection in the records
352 database, use the following invocation at the system shell:
353
354 mongofiles -d records list
355
356 This mongofiles instance will connect to the mongod instance running on
357 the 27017 localhost interface to specify the same operation on a dif‐
358 ferent port or hostname, and issue a command that resembles one of the
359 following:
360
361 mongofiles --port 37017 -d records list
362 mongofiles --hostname db1.example.net -d records list
363 mongofiles --hostname db1.example.net --port 37017 -d records list
364
365 Modify any of the following commands as needed if you're connecting the
366 mongod instances on different ports or hosts.
367
368 To upload a file named 32-corinth.lp to the GridFS collection in the
369 records database, you can use the following command:
370
371 mongofiles -d records put 32-corinth.lp
372
373 To delete the 32-corinth.lp file from this GridFS collection in the
374 records database, you can use the following command:
375
376 mongofiles -d records delete 32-corinth.lp
377
378 To search for files in the GridFS collection in the records database
379 that have the string corinth in their names, you can use following com‐
380 mand:
381
382 mongofiles -d records search corinth
383
384 To list all files in the GridFS collection in the records database that
385 begin with the string 32, you can use the following command:
386
387 mongofiles -d records list 32
388
389 To fetch the file from the GridFS collection in the records database
390 named 32-corinth.lp, you can use the following command:
391
392 mongofiles -d records get 32-corinth.lp
393
395 MongoDB Documentation Project
396
398 2011-2015
399
400
401
402
4033.0 January 30, 2015 MONGOFILES(1)