导出查询数据 使用javascript导入,下面文件命名为dump.js 1 2 3 4 5 6 7 8 9 db.auth("teddy_bbc","teddy_bbc123"); var c = db.adStatDTO.aggregate([{ "$match" : { "actionType" : 3, "clickTime" : { "$gte" : "1540828800000", "$lte" : "1540915199000"} } }] ); while(c.hasNext()) { printjson(c.next()); } 在命令行执行 1 /usr/local/mongodb-linux-x86_64-3.4.1/bin/mongo xxxx:3717/dump.js> result.js 导入 1 mongoimport -d bbc_ad_stat -c adStatDTO --file result.js --headerline --type json/csv -f field