Export MySql data in following command.
SELECT id,documentfile
FROM documentuploads
INTO OUTFILE '/home/home2/agri_doc.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
CSV file data
"3","%PDF-1.7\
%����\
1 0 obj\
<<\
/Type /Catalog\
/Pages 2 0 R\
>>\"
I am currently using mongodb shell version v3.6.3. i want to import my csv file in mongo database, and I have created a collection documentupload where only two field id, docs. data is latin1_swedish_ci encoded. I tried following command.
mongorestore -d agrilicense2 -c documentupload --type csv --file /home/shiva/home/agri_doc3.csv --fields id, docs --headerline
Show output
error parsing command line options: unknown option "type"
Thank you
Best Answer
You can import the (.csv) file through the following commands
For example here I have created the database name test and collection name StackExchange and going to import the LocarionReq.csv file.
Now you can check the total document records through the mongo shell command
If you want to find the document records through mongo shell then run the command such as
For your further ref here