5.MongoDB的备份恢复

备份的语法:

mongodump -h dbhost -d dbname -o dbdirectory

-h: 服务器地址, 也可以指定端⼝号
-d: 需要备份的数据库名称
-o: 备份的数据存放位置, 此⽬录中存放着备份出来的数据

mongodump -h 192.168.196.128:27017 -d test1 -o ~/Desktop/test1bak

恢复语法:

 mongorestore -h dbhost -d dbname --dir dbdirectory

-h: 服务器地址
-d: 需要恢复的数据库实例
–dir: 备份数据所在位置

mongorestore -h 192.168.196.128:27017 -d test2 --dir ~/Desktop/test1bak/test1
发布了60 篇原创文章 · 获赞 8 · 访问量 3318

猜你喜欢

转载自blog.csdn.net/qq_43476433/article/details/103639822