从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前有两个“-”号,使用一个“-”会报错







posted @ 2017-01-20 14:55  理舞  阅读(5299)  评论(0编辑  收藏  举报