-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmongo-command-mongolab.txt
More file actions
34 lines (25 loc) · 1.68 KB
/
mongo-command-mongolab.txt
File metadata and controls
34 lines (25 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Import / Export Helper
MongoDB provides two mechanisms for importing and exporting data. One way is via the mongoimport and mongoexport utilities. These allow you to import and export JSON and CSV representations of your data. The other way is with mongorestore and mongodump utilities which deal with binary dumps.
In this tab we provide pre-filled strings for the commands that we find most useful.
Copy and paste from below to import or export from this database. For a full list of options
that can be used with these commands, please see MongoDB's documentation on this subject.
Binary
Import database
mongorestore -h ds031613.mongolab.com:31613 -d inventory -u <user> -p <password> <input db directory>
Export database
mongodump -h ds031613.mongolab.com:31613 -d inventory -u <user> -p <password> -o <output directory>
Import collection
mongorestore -h ds031613.mongolab.com:31613 -d inventory -u <user> -p <password> <input .bson file>
Export collection
mongodump -h ds031613.mongolab.com:31613 -d inventory -c <collection> -u <user> -p <password> -o <output directory>
JSON
Import collection
mongoimport -h ds031613.mongolab.com:31613 -d inventory -c <collection> -u <user> -p <password> --file <input file>
Export collection
mongoexport -h ds031613.mongolab.com:31613 -d inventory -c <collection> -u <user> -p <password> -o <output file>
CSV
Import collection
mongoimport -h ds031613.mongolab.com:31613 -d inventory -c <collection> -u <user> -p <password> --file <input .csv file> --type csv --headerline
Export collection
mongoexport -h ds031613.mongolab.com:31613 -d inventory -c <collection> -u <user> -p <password> -o <output .csv file> --csv -f <comma-separated list of field names>
By Amran