从MySQL中导入数据到MongoDB中

Posted 理舞

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从MySQL中导入数据到MongoDB中相关的知识,希望对你有一定的参考价值。

从sql中导出需要的数据为csv格式的数据
select field1,field2,...,fieldn from TABLE into outfile /test.csv fields terminated by , optionally enclosed by "" escaped by "" lines terminated by \r\n;

将test.csv数据导入到mongodb中,本人使用的是mongodb-3.2

mongoimport -h "localhost" -d "DATABASE" -c "COLLECTION" -f "field1,field2,...fieldn" --type csv -file "c:\test.csv"

注意:我在在type前有两个“-”号,使用一个“-”会报错













以上是关于从MySQL中导入数据到MongoDB中的主要内容,如果未能解决你的问题,请参考以下文章