This issue据说解决了最新版本的Moped,但仍然发生在我身上。 我有一个Rails 4.2的应用程序与Mongoid,创造了一个MongoDB的DB用户与读写和的dbowner的角色,并在mong.conf文件中设置AUTH =真。
我可以使用Mongo shell或使用Mongo驱动程序的简单Java应用程序,使用该用户凭据在数据库上执行任何操作。
但是,试图与Mongoid进行身份验证时,我总是得到这个错误:Rails Mongoid未通过身份验证 - 失败,错误13:“未授权查询my_db.my_collection”
failed with error 13: "not authorized for query on my_db.my_collection"
这里是我的mongoid.yml文件的相关部分:
production:
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: my_db
hosts:
- localhost:27017
username: my_username
password: my_password
我也试过更换具有远程服务器地址的主机并远程访问它(与禁用身份验证选项配合使用),但未成功。 值得一提的是,我可以通过调试mpped/node.rb文件,在ensure_connected方法中看到@credentials变量包含我的用户名和密码 我在这里丢失了什么? 谢谢!
http://stackoverflow.com/questions/17376250/ruby-on-rails-mongoid-and-webfaction-not-authorized-for- query-error-16550 –
谢谢,但正如我所说我也使用readWrite角色,它从其他客户端。这不是正确的答案 – Orr
如果您将用户升级为键入[dbOwner](http://docs.mongodb.org/manual/reference/built-in-roles/#dbOwner),错误是否仍然存在? – Drakes