douzhuanqian8244 2016-08-03 04:47 采纳率: 100%
浏览 1791
已采纳

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

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)

}
  • 写回答

7条回答 默认 最新

  • dpzbzp8728 2017-05-02 17:30
    关注

    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/
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部