Far*_*rin 9 json mongodb mongoexport mongodb-atlas mongodb-compass
我在 Atlas 中有名为“test”的远程数据库,我想将集合名称 image_table 作为 JSON 文件下载。
在mac终端中:
$ mongoexport –db test –collection image_table image.json 我得到了错误>
020-01-16T13:49:12.822+0100 错误解析命令行选项:位置参数太多:[–db test –collection image_table image.json] 2020-01-16T13:49:12.822+0100 试试 'mongoexport --help ' 想要查询更多的信息
MongoDB Compass 有很多缺陷,即使执行导出集合这样的微不足道的任务,您也可能会失败。例如,它会跳过导出中的某些字段。应用程序本身说:“显示的字段来自集合中的文档样本......”。根据我的经验,Compass 使用的示例非常小。即使导出 100 个左右的文档,我也丢失了数据。
使用mongoexport很容易。如果您使用 mongo 3.6+,这将起作用:
mongoexport --uri mongodb+srv://<username>@atlas-cluster-url.mongodb.net/<db-name> --collection <collection-name> --out <path-to-export>
我可以在 Mongo Compass 中找到更直接的答案:
只需将 mongo compass connect 安装到您的 atlas 远程数据库:从您的远程 altas 集群获取像“cluster0-shard-00-00-rcapo.mongodb.net XXXXX”这样的主机名,然后连接到数据库。
然后您可以将每个文档下载为 JSON 或 CSV 格式。谢谢,mongo DB 指南针开发团队。
| 归档时间: |
|
| 查看次数: |
12709 次 |
| 最近记录: |