HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

mongorestore — Utility to import a collection or database from a binary dump into a MongoDB instance. More informat

Submitted by: @import:tldr-pages··
0
Viewed 0 times
importcommandfromcollectiondatabaseclimongorestoreutility

Problem

How to use the mongorestore command: Utility to import a collection or database from a binary dump into a MongoDB instance. More information: <https://www.mongodb.com/docs/database-tools/mongorestore/>.

Solution

mongorestore — Utility to import a collection or database from a binary dump into a MongoDB instance. More information: <https://www.mongodb.com/docs/database-tools/mongorestore/>.

Import a BSON data dump from a directory to a MongoDB database:
mongorestore --db {{database_name}} {{path/to/directory}}


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):
mongorestore --host {{database_host:port}} --db {{database_name}} --username {{username}} {{path/to/directory}} --password


Import a collection from a BSON file to a MongoDB database:
mongorestore --db {{database_name}} {{path/to/file}}


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):
mongorestore --host {{database_host:port}} --db {{database_name}} --username {{username}} {{path/to/file}} --password

Code Snippets

Import a BSON data dump from a directory to a MongoDB database

mongorestore --db {{database_name}} {{path/to/directory}}

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)

mongorestore --host {{database_host:port}} --db {{database_name}} --username {{username}} {{path/to/directory}} --password

Import a collection from a BSON file to a MongoDB database

mongorestore --db {{database_name}} {{path/to/file}}

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)

mongorestore --host {{database_host:port}} --db {{database_name}} --username {{username}} {{path/to/file}} --password

Context

tldr-pages: common/mongorestore

Revisions (0)

No revisions yet.