文档格式分为json和csv两种,现在分别介绍这两种文档的导出方法
使用工具介绍:
mongoexport,为MongoDB数据导出工具。注意不能直接在bin文件夹下直接运行mongoexport.exe
格式介绍:
mongodbexport -h host -d db -c collection -o file --type json/csv -f "(如果type为csv,则要写-f。导出数据内容)"
1.连接MongoDB:
1.1.管理员身份运行cmd,进入自己MongoDB安装路径的bin文件夹
例:我的路径所在:E:\My_pan\MongoDB\Server\4.0\bin
E:\>cd My_pan\MongoDB\Server\4.0\bin
1.2.输入连接命令:
>net start mongodb
显示连接成功的信息:
2.1.输入导出命令,导出为json文件
> mongoexport -h host -d db -c collection -o file
例:我的主机地址是127.0.0.1