

Use the mongoimport command like this: sudo mongoimport -db newdb -collection restaurants -file primer-dataset.json. Let’s import the data from this file into a new database called newdb and into a collection called restaurants.
#Download mongodb collection as json download#
-c: The name of the new collection you are creating. Once the download completes you should have a file called primer-dataset.json (12 MB size) in the current directory.-uri: The cluster’s connection string to the target database.The mongoimport command requires the cluster’s connection string to the target database and values for the following flags: Example query: Here conduct is the database from which webinars collection is being exported. To import the database, use the mongoimport command. A MongoDB instance running on port 27017, doesn’t necessarily require a host or port to be specified. To import a database with the MongoDB command line client, the exported database file must be stored locally on the same machine as your client. Import with the MongoDB Command Line Client To get the database’s connection parameters from your control panel, visit the Databases page, open the database’s More menu, then select Connection details and click Flags. If you are experimenting with MongoDB, you can download a sample database file from MongoDB’s official website.

The database file stored locally on the same machine as your MongoDB client in JSON, CSV, SQL, or BSON format. To import databases with the DigitalOcean Managed Databases MongoDB engine, you will need:Ī MongoDB client, like the MongoDB Community Edition.

Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is a source-available cross-platform document-oriented database program for high-volume storage.
