2016-09-05 21:52:20 +01:00
# mongorestore
> Utility to import a collection or database from a binary dump into a MongoDB instance.
2021-04-03 20:41:51 +01:00
> More information: <https://docs.mongodb.com/database-tools/mongorestore/>.
2016-09-05 21:52:20 +01:00
2021-08-15 18:59:09 +01:00
- Import a BSON data dump from a directory to a MongoDB database:
2016-09-05 21:52:20 +01:00
2019-02-11 18:00:49 +00:00
`mongorestore --db {{database_name}} {{path/to/directory}}`
2016-09-05 21:52:20 +01:00
2021-08-15 18:59:09 +01:00
- Import a BSON data dump from a directory to a given database in a MongoDB server host, running at a given port, with user authentication (user will be prompted for password):
2016-09-05 21:52:20 +01:00
2019-02-11 18:00:49 +00:00
`mongorestore --host {{database_host:port}} --db {{database_name}} --username {{username}} {{path/to/directory}} --password`
2016-09-05 21:52:20 +01:00
2021-08-15 18:59:09 +01:00
- Import a collection from a BSON file to a MongoDB database:
2016-09-05 21:52:20 +01:00
`mongorestore --db {{database_name}} {{path/to/file}}`
2021-08-15 18:59:09 +01:00
- Import a collection from a BSON file to a given database in a MongoDB server host, running at a given port, with user authentication (user will be prompted for password):
2016-09-05 21:52:20 +01:00
`mongorestore --host {{database_host:port}} --db {{database_name}} --username {{username}} {{path/to/file}} --password`