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
Related
I am currently trying to import a group of JSON files containing data into my mongo database hosted on IBM Bluemix/Compose.
I have a script that runs through the files creating and then running a mongoimport command to import the files into the database, this works great against my local database(and indeed occasionally against the Compose database) however most of the time I get the following error -
2017-05-09T14:59:02.508+0100 Failed: error connecting to db server:
SSL errors: x509 certificate routines:X509_STORE_add_cert:cert
already in hash table x509 certificate
2017-05-09T14:59:02.508+0100 imported 0 documents
My mongoimport command looks like this -
mongoimport --batchSize 100 --ssl --sslAllowInvalidCertificates --host *censored* --collection Personnel --file data/TestData/Personnel_WICS.json -u admin -p *censored* -d MY_DB --authenticationDatabase admin
Is this a mongoimport error? Perhaps an issue with Compose? Or am I doing something incorrectly with the command?
I should note that the files I am importing range in size from 3mb-100mb, but even reducing the larger file sizes down by splitting them up does not seem to help.
My import script runs one import command immediately following the completion of the previous one, is there maybe some issue in running several back to back imports like this?
For anyone finding this in future - it looks like this may have been caused by a mismatch in mongo versions between the machine I'm running the mongoimport command from and the mongo database hosted in compose.
Compose DB Version: 3.2
Build server machine(running mongoimport): 3.4
Downgrading the build server version has resolved the issue.
I need one help. I need to export and import the total database/all collection for MongoDB using Ubuntu. I am explaining my command below.
sudo mongoexport --db FGDP --out /home/subrajyoti/Downloads/newdbexport.json;
Here i am getting the following error message.
2016-12-22T10:28:46.290+0530 error validating settings: must specify a collection
2016-12-22T10:28:46.290+0530 try 'mongoexport --help' for more information
Here i need to export all collection rather than one single one. Please help me.
Exporting all collections of all database using mongodump use the following command:
mongodump -o <directory_backup>
I am learning MongoDB and for practice i downloaded the restaurant data from mongodb site. I am using windows OS and mongo is installed properly.
Now, I want to insert all the restaurant documents ( i.e json data) to mongodb. I am using cmd and tried this command
mongoimport --db test --collection restaurants --drop --file ~/downloads/primer-dataset.json
but it failed and got the message that
SyntaxError: missing ; before statement #(shell):1:4
How to solve this error? Please help me because I couldn't find satisfactory answer even after spending too much time.
mongoimport must be run from the Windows command prompt, not the mongo shell.
I have an application which collects Email, Phone number, Address etc. I want to get this data from meteor mongo db and export it into some kind of a file format (Maybe CSV).
I tried using mongoexport but that even didnt work.
mongoexport
Whats the command to export meteor database data into a file or is there any kind of package.
FYI: application is stored on amazon ec2 instance.
You can still use mongoexport, you just need to point it at the meteor-internal mongodb:
mongoexport --port=3001
Just make sure meteor is running when you issue this command.
This is assuming you are running in development (using meteor, not a bundle), and using the default port (3000).
How is it possible to Import and export the MongoDB from Meteor APP into .json or .csv file ?
You can use mongoexport utility to export into a .json or .csv file and mongoimport to import to your db. Detailed info is found here: http://docs.mongodb.org/v2.2/reference/mongoexport/
If you intend to reimport into mongodb, mongodump might be a bit better since you won't be losing type information
Try mongodump
mongodump --host 127.0.0.1:3001
Here you get BSON, and separate key indexes in json files. Then you can use the dumps to restore your db (if this is your intention):
If you're in the dump directory from above:
mongorestore --host 128.199.224.29:27017 --db meteor .