简体   繁体   English

如何将 mongodb 从 windows 机器备份到 mac os?

[英]How to backup mongodb from windows machine to mac os?

I am new to mongodb.我是 mongodb 的新手。 I have a mongodb database of 2gb size in windows machine.我在 Windows 机器上有一个 2gb 大小的 mongodb 数据库。 I want to backup and restore it to my mac os.我想备份并将其恢复到我的 mac os。 I tried copying and pasting the /data/db folders from windows to my mac machine.我尝试将 /data/db 文件夹从 Windows 复制并粘贴到我的 mac 机器上。 But it didn't work.但它没有用。 The database is not showing up in mac on doing this.执行此操作时,数据库未显示在 mac 中。 I guess I missing something majorly.我想我主要遗漏了一些东西。 Can someone assist me on this?有人可以帮助我吗?

Thanks in advance!提前致谢!

Try exporting mongoDB to a JSON file using command :尝试使用命令将 mongoDB 导出到 JSON 文件:

mongoexport --host "localhost:27017" --collection coll_Name --db db_Name --any_file_Name "path to get the any_file_Name.json file" mongoexport --host "localhost:27017" --collection coll_Name --db db_Name --any_file_Name "获取 any_file_Name.json 文件的路径"

And to import this json in mac type command :并在 mac 类型命令中导入此 json:

mongoimport --db db_Name --collection coll_Name --file "any_file_Name.json path" mongoimport --db db_Name --collection coll_Name --file "any_file_Name.json 路径"

您应该使用back 和 restore

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM