当前位置:Gxlcms > 数据库问题 > mongodb 的备份恢复导入与导出

mongodb 的备份恢复导入与导出

时间:2021-07-01 10:21:17 帮助过:6人阅读

:\mongodb\bin>mongodump.exe --help >f:/mongodump-help.txt
  • F:\mongodb\bin>mongorestore.exe --help >f:/mongorestore-help.txt
  • 技术分享

    备份mongodump  /h localhost /port 27017 /u admin /p 123 /authenticationDatabase:admin /d hndb /o c:/
    备份指定库指定表 hndb 集合s 压缩备份mongodump  /h localhost /port 27017 /u admin /p 123 /authenticationDatabase:admin /d hndb /c s /o c:/ /gzip

    备份指定库指定表 hndb 所有信息 备份到c:/hndb.zip文件中mongodump  /h localhost /port 27017 /u admin /p 123 /authenticationDatabase:admin /d hndb /archive:c:/hndb.zip
    恢复mongorestore  /h localhost /port 27017 /u admin /p 123 /authenticationDatabase:admin /d hndb /dir c:/hndb/
    恢复指定的备份,gzip格式mongorestore  /h localhost /port 27017 /u admin /p 123 /authenticationDatabase:admin /d hndb /dir:c:/hndb/ /gzip
    恢复 hndb 所有信息 从文件c:/hndb.zipmongorestore  /h localhost /port 27017 /u admin /p 123 /authenticationDatabase:admin /d hndb /archive:c:/hndb.zip


    数据库的导出
    1. F:\mongodb\bin>mongodump /h localhost /port 27017 /u admin /p admin /authentica
    2. tionDatabase:admin /d hndb /o c:/

    技术分享
    删除表> db.book.drop();true删除库> db.dropDatabase();{ "dropped" : "hndb", "ok" : 1 }删除库表,然后备份恢复
    1. F:\mongodb\bin>mongorestore /h localhost /port 27017 /u admin /p admin /authent
    2. icationDatabase:admin /d hndb /dir c:/hndb/
    压缩文件的导出
    1. 备份指定库指定表 hndb 所有信息 备份到c:/hndb.zip文件中
    2. mongodump /h localhost /port 27017 /u admin /p admin /authenticationDatabase:admin /d hndb /archive:c:/hndb.zip
    删除库表,压缩文件的导入
    1. 恢复 hndb 所有信息 从文件c:/hndb.zip
    2. mongorestore /h localhost /port 27017 /u admin /p admin /authenticationDatabase:admin /d hndb /archive:c:/hndb.zip
    只导出stu压缩文件到hndb里面
    1. F:\mongodb\bin>mongodump /h localhost /port 27017 /u admin /p admin /authentica
    2. tionDatabase:admin /d hndb /c stu /o c:/ /gzip
    恢复指定的备份,gzip格式
    1. 恢复指定的备份,gzip格式
    2. mongorestore /h localhost /port 27017 /u admin /p admin /authenticationDatabase:admin /d hndb /dir:c:/hndb/ /gzip





    来自为知笔记(Wiz)

    mongodb 的备份恢复导入与导出

    标签:

    人气教程排行