can connect to mlab but unable to import the document - mongodb

I am connecting to mlab using the mongo import command to import the json collection.
Now i am able to connect to mlab. However, it does not import the document.
imported 0 documents
I have created the input file (test.json) in C:/data/db folder.
The foll is an illustration of the command:
I'd appreciate any guidance on where i am going wrong with this.

Related

Importing data into MongoDB Atlas

I have a local database/collection that I created from an external .bson file using mongorestore. I'm able to access the collection from my local machine, however, it's not updated in MongoDB Atlas.
How exactly can I import it? It seems that mongoimport only works with json files.

Error importing collections into a mongodb database on an ec2 instance

I exported the collections from a local database and I want to import them into an ec2 instance.
I did the following:
1) I exported the collections to a folder called data. The files are in this format:
collecion_test.bson
collection.metadata.json
2) I transferred the folder to an ec2 instance. The path to access the folder is like this:
/home/ec2-user/data
3) I went into mongo and did "use database_test" and created a collection like this: db.createCollection("data")
Finally, I tried to import the file this way:
mongoimport --db database_test --collection data --file /home/ec2-user/data/data.metadata.json -jsonArray
but I get this error:
2022-02-18T19:29:38.380+0000 E QUERY [js] SyntaxError: missing ; before statement #(shell):1:14
I appreciate if anyone can help me analyze this!
The problem is that you used mongodump which created the xxx.bson and xxx.meta.json so you need to use mongorestore to read those files. Use mongoimport to read files created with mongoexport
for a full explanation see https://docs.mongodb.com/database-tools/
In short mongodump/mongorestore deal with bson files while mongoexport/mongoimport work with csv/tsv/json files. So for example one neat thing about these commands, is if you supply an optional -q parameter like {field:x} then only the records that filter would select will be used in the dump.

how to import database in mongodb v5?

I'm new on learning MongoDB ,
I'd like to import a JSON file to create a new database using the command mongoimport
as I'm using windows I tried to add the executable file name of mongoimport to the environment path for easy access it but I didn't find the file in the path, I saw tutors on YouTube have it on version 4 but not exist in v5
this screen from v5 that I have:
and this from v4 (captured from youtube tut):
mongoexport
mongoexport mongodb://localhost:27017 -c=exportcollection --db=mydb --out=exportfile.json
mongoimport
mongoimport mongodb://localhost:27017 -c=newcollection --db=mydb exportfile.json

Import data from MondoDB localhost to MongoDB Atlas

I have this database in MongoDB Compass interface which is stored (not sure if this is the right way to describe it) in localhost:
enter image description here
Is there a way to export the data from there and import it into MongoDB cloud version?
Thank you!
first connect mongodb compass to local db and exports data , then connect mongodb compass to mongo atlas and import exported data

MongoLab syntax error on import command

I'm trying to import data into a MongoLab hosted mongo database. I keep getting syntax errors. I've used the tools->Pre-filled commands but it's not working.
Actually when I copy/paste from the Pre-filled example, the % doesn’t show in the command line tool. Should it be a ‘%’ as it shows in the 'helper' or is it an error in html encoding?
I've got no experience with MongoLab nor with MongoDB for that matter. Can anyone advise me about MongoLab as a hosting service for my Mongo db?
Thanks