【MongoDB】4.4版本。备份到文件从文件引入。mongoimport mongoexport

    科技2022-07-16  123

    文档

    https://docs.mongodb.com/database-tools/mongoimport/

    安装(4.4以上)

    地址:https://www.mongodb.com/try/download/database-tools?tck=docs_databasetools 分流:https://pan.baidu.com/s/1fI6GRAgGk0g_hIX0ZgDhXg 提取码:9xpg

    查了半天资料,mongoimport mongoexport就是报错。重新安装mongodb,重新设置path,重启,都不行。 最后上官网查文档才知道,4.4以上,这些工具分离出去了,MongoDB不自带。 总之,4.4版本以上的去下载上面的文件,解压,把其中的bin覆盖掉MongoDB安装目录下的bin就行了。

    下面是基础的导出,引入的指令 通用参数: -u 用户名 -p 密码 -d 指定数据库 -c 指定集合 export需要添加 -o 输入文件路径 import需要添加 --file 输出文件路径

    mongoexport -u test -p 123456 -d todolist -c counters -o "./counters .json" mongoimport -u test -p 123456 -d todolist -c counters --file "./counters .json"

    从路径引入 mongorestore --authenticationDatabase admin -u root -p 123456 -d blog .\blog ps:不加 --authenticationDatabase 会报错 error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism “SCRAM-SHA-1”: (AuthenticationFailed) Authentication failed.

    Processed: 0.010, SQL: 8