从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前有两个“-”号,使用一个“-”会报错
时间: 2024-10-10 04:31:02