解决Docker中备份mongodb不成功问题。报错原因:error occured during connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1"
1.进入容器:
docker ps
docker exec -it 容器名/ID bash
备份mongodb命令:mongodump -h 172.19.19.41 --port 27017 -u='admin' -p='********' -d ******* -o ./backup/
出现报错:Failed: can't create session: could not connect to server: connection() error occured during connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.
解决方法:
添加参数:--authenticationDatabase admin
参数含义:
解释1.安全登录认证,mongodb本身的一种安全认证登录方式,参数就相当于指定admin数据库。
解释2.在连接mongo时,使用参数 --authenticationDatabase,会认证 -u 和 -p 参数指定的账户和密码。如果没有指定验证数据库,mongo使用连接字符串中指定的DB作为验证数据块。
修改后为:mongodump -h 172.19.19.41 --port 27017 --authenticationDatabase admin -u='admin' -p='*******' -d ******* -o ./backup/
ok!正常备份!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!