mongo数据迁移

编程知识 更新时间:2023-05-02 21:15:26

1.数据备份(数据库)

使用mongodump进行mongo数据库备份:
命令:mongodump --host localhost -u root -p root -d vlog -o /root/dump --authenticationDatabase admin
参数解释:
–host: 服务器名称或IP:PORT
-u: 用户名
-p: 密码
-d: 数据库dbname
-o:导出文件的存放路径
–authenticationDatabase admin: 添加–authenticationDatabase admin 参数制定认证数据库
解决报错:Failed: can’t create session: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism “SCRAM-SHA-1”: (AuthenticationFailed) Authentication failed.

2.数据恢复(数据库)

命令:mongorestore -h localhost -u root -p root123 --db admin dump/test_jia/ --authenticationDatabase admin
-h: 服务器名称或IP:PORT
-u: 用户名
-p: 密码
–db: 数据库dbname,需要恢复的数据库名称
dump/test_jia/:恢复文件的存储路径
–authenticationDatabase admin: 添加–authenticationDatabase admin 参数制定认证数据库
报错场景:
1.-u root -p root123 --authenticationDatabase admin三个参数都未设置时报错:
Failed: error getting auth version of server: (Unauthorized) command getParameter requires authentication
2.-u root -p root123或–authenticationDatabase admin未设置时报错:
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.

更多推荐

mongo数据迁移

本文发布于:2023-04-28 17:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/2821af7789408595ae18481cdf38b76c.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   mongo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 109255文章数
  • 27726阅读数
  • 0评论数