mongodb备份和还原

    xiaoxiao2022-06-29  45

    连接远程的mongodb数据库:

    mongo 192.168.0.254:27017/testdb

    然后cd ../

    备份mongodb数据库:

    mongodump -h 192.168.0.254 -d testdb -o D:\InstallDir\MongoDB

    -h 参数localhost是指对应mongodb服务器的ip

          -d参数testdb是对应的数据库名称

    还原mongodb数据库:

    这里我先删除了原来的数据库执行的命令是:

    ->show dbs;

    ->use testdb;

    ->db.dropDatabase();

    此时执行还原命令:

    mongorestore -h localhost -d testdb2 D:\InstallDir\MongoDB\testdb

         -d参数testdb2可以与要导入的数据库名不同

    转载请注明原文地址: https://ju.6miu.com/read-1125399.html

    最新回复(0)