服务器在SASL身份验证步骤返回错误:身份验证失败

编程入门 行业动态 更新时间:2024-10-28 01:12:19
本文介绍了服务器在SASL身份验证步骤返回错误:身份验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

以下是GoLang的MongoDB连接拨号。但是它正在返回一个恐慌SAS服务器在SASL身份验证步骤返回错误:身份验证失败。。我的用户名,密码,hostAddrs和dbName都是正确的。

dbName:= os.Getenv(ENV_DBNAME) userName:= os。 Getenv(ENV_DBUSER)密码:= os.Getenv(ENV_DBPASS) dbHost:= os.Getenv(ENV_DBHOST) mongoDialInfo:=& mgo.DialInfo { Addrs:[] string { dbHost },数据库:dbName,用户名:userName,密码:password,超时:60 * time.Second,} sess,err:= mgo.DialWithInfo(mongoDialInfo) if(err!= nil){ panic(err ) }

解决方案

I面临类似的错误,并添加了 - authenticationDatabase 参数,并且它在我们连接到远程MongoDB时起作用 使用类似在你的代码格式下:

$ mongorestore --host databasehost:98761 --username restoreuser --password restorepwd --authenticationDatabase admin --db targetdb ./path/to/dump/

The following is my MongoDB connection dial from GoLang. But it's returning a panic "server returned error on SASL authentication step: Authentication failed.". My username, password, hostAddrs and dbName are correct. What am I missing here?

dbName: = os.Getenv("ENV_DBNAME") userName: = os.Getenv("ENV_DBUSER") password: = os.Getenv("ENV_DBPASS") dbHost: = os.Getenv("ENV_DBHOST") mongoDialInfo: = & mgo.DialInfo { Addrs: [] string { dbHost }, Database: dbName, Username: userName, Password: password, Timeout: 60 * time.Second, } sess, err: = mgo.DialWithInfo(mongoDialInfo) if (err != nil) { panic(err) }

解决方案

I faced similar error and added --authenticationDatabase parameter and it worked while we connecting to a remote MongoDB

Use the similar below format in your code :

$mongorestore --host databasehost:98761 --username restoreuser --password restorepwd --authenticationDatabase admin --db targetdb ./path/to/dump/

更多推荐

服务器在SASL身份验证步骤返回错误:身份验证失败

本文发布于:2023-10-13 00:38:04,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:身份验证   步骤   错误   服务器   SASL

发布评论

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

>www.elefans.com

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