server returned error on SASL authentication step: Authentication failed

后端 未结 7 1332
死守一世寂寞
死守一世寂寞 2020-12-12 20:14

The following is my MongoDB connection dial from GoLang. But it\'s returning a panic \"server returned error on SASL authentication step: Authentication failed.\".

相关标签:
7条回答
  • 2020-12-12 20:48

    mgo returns this error if username, password or database are wrong. Check your credentials twice. There are no other situations when you can see Authentication failed error message.

    0 讨论(0)
  • 2020-12-12 20:50

    I got this error while using a connection string from a Heroku app by means of the --uri flag. What solved it in my case was adding the database name with -d:

    mongodb_uri="$(heroku config:get MONGODB_URI -a myapp)"
    mongorestore --uri=$mongodb_uri -d heroku_7m41q4xs db/
    
    0 讨论(0)
  • 2020-12-12 20:54

    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/
    
    0 讨论(0)
  • 2020-12-12 20:56

    I got my answer from this link: https://newbiedba.wordpress.com/2016/11/21/mongodb-3-2-server-returned-error-on-sasl-authentication-step-authentication-failed/

    Except for all answers above, the only unmentioned reason is that my password has a special character '$' in it. I think this is a very common practice to have special characters and this may trip many without this simple tip:

    When using command line mongo/mongostat/etc.. Single quote your username or password that has special characters!

    0 讨论(0)
  • 2020-12-12 21:03

    I had the same error when using with dokku mongo:import . In my case I included dot(period) in my db name

    You shouldn't include dot in your mongodb name when 'dokku mongo:create ' I've changed it to seunghunlee instead of seunghunlee.net now this command works

    dokku mongo:import seunghunlee < seunghunlee.net.dump.gz
    

    Hope it helps!

    0 讨论(0)
  • 2020-12-12 21:04

    The error you report seem the cause of the authentication fail is caused by a nil pointer, you should check the data before using them to create the connection

    0 讨论(0)
提交回复
热议问题