Heroku could not authenticate mongolab

旧时模样 提交于 2020-01-03 16:36:20

问题


It was corrected two days ago. And yesterday I committed some changes to heroku and the application crashed, I found from heroku logs that:

/app/.bundle/gems/ruby/1.9.1/gems/mongo-1.4.0/lib/mongo/db.rb:137:in `issue_authentication': Failed to authenticate user 'larryzhao' on db 'uthenera' (Mongo::AuthenticationError)

I even explicitly input the host/port/username/password/db name into mongoid.yml, still it could not get pass authentication.

I tried both database in Rackspace and in Amazon, but neither could authenticate.

Have you met with that before? Is there anything else I could check on Heroku besides heroku logs ?

Thanks.


回答1:


Make sure you're using the right username to connect to your database. The username you use to log into mongolab.com is different from the one attached to the 'uthenera' database. Have a look at the Users tab for that database at mongolab.com to see what database user(s) you've configured.

Hope that helps. Feel free to email support@mongolab.com if you need further assistance.

-Robert




回答2:


Today I encountered the same on Heroku:

Mongo::AuthenticationError: Failed to authenticate user 'heroku_app111' on db 'heroku_app111'.
        from /home/ad/.rvm/gems/ruby-2.1.3@app/gems/mongo-1.11.1/lib/mongo/functional/authentication.rb:205:in `issue_authentication'

It's not because of this RUBY-890 bug, but because MongoLab upgraded to MongoDB 3.0 which uses SCRAM-SHA-1 challenge-response user authentication mechanism. So I needed latest ruby mongo driver version which is counting with this. In my case latest 1.x branch.

The minimum driver versions that support SCRAM-SHA-1 are:

Driver     Language Version
C          1.1.0
C++        1.0.0
C#         1.10
Java       2.13
Node.js    1.4.29
Perl       0.708.0.0
PHP        1.6
Python     2.8
Motor      0.4
Ruby       1.12
Scala      2.8.0

Of course you have to be sure your credentils are ok :)




回答3:


You can get your database username and password using:

heroku config | grep MONGODB_URI

The response is in this format:

MONGOLAB_URI: mongodb://username:password@mlab.com:12345/db



来源:https://stackoverflow.com/questions/7692323/heroku-could-not-authenticate-mongolab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!