mongo导出数据为txt

本意是想将json数据导入mysql,搜索办法需要安装mysqljsonimport这款工具,安装失败,于是便想将mongo里的数据直接txt导出

原来的数据格式是json,长这样

导出命令:mongoexport.exe -h localhost:27017 -d weibo-110 -c Fans -o d://Fans.txt

D:MongoDBin>mongoexport.exe -h localhost:27017 -d weibo-110 -c Fans -o d://Fans.txt
2020-03-14T20:58:08.425+0800    connected to: mongodb://localhost:27017/
2020-03-14T20:58:09.166+0800    exported 24119 records

参数说明:
    -h 数据库地址
    -d 指明使用的库
    -c 指明要导出的集合
    -o 指明要导出的文件名(文件支持多种格式,如txt,wps,xls等)

导出的txt文档

启动mongo

1.mongod.exe --dbpath d:MongoDBdatadb

2.另外开一个cmd窗口输入mongo

原文地址:https://www.cnblogs.com/blackicelisa/p/12494288.html