-1

I have mongo db dump which has

.bson

and

.json

files. How can i import this database in monodb through command line?

Suraj Maurya
  • 43
  • 3
  • 7

2 Answers2

1

Import a .bson file:

mongorestore -d db_name -c collection_name path/file.bson

For Json try this

mongoimport --db dbName --collection collectionName <fileName.json>
Harshil
  • 463
  • 1
  • 8
  • 28
0

Use mongorestore to dump bson files, and use mongoimport to import json files.

Example:

Mongo Restore (without Authentication)

mongorestore dump-2013-10-25/

Mongo Restore (with Authentication)

mongorestore --host mongodb1.example.net --port 3017 --username user --password pass /opt/backup/mongodump-2013-10-24

MongoImport (without Authentication)

mongoimport --db users --collection contacts --file contacts.json

MongoImport (with Authentication)

mongoimport --host mongodb1.example.net --port 37017 --username user --password pass --collection contacts --db marketing --file /opt/backups/mdb1-examplenet.json

Refer: Link

Gaurav Dave
  • 6,838
  • 9
  • 25
  • 39