解決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!正常備份!

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM