Rails + Mongodb 应用,部署的时候为项目数据库添加了一个用户,给了 readWrite 权限,然后在rails中配置好之后报错,说是没有权限获取数据,但是在mongo的控制台用该用户登录是可以查询数据的。
mongoid.yml
yml
production: sessions: default: hosts: - localhost:27017 database: db username: user password: password options: include_root_in_json: true include_type_for_serialization: true scope_overwrite_exception: true raise_not_found_error: false use_activesupport_time_zone: false use_utc: true
mongo db db.getUsers()
[
{
"_id" : "db.dbuser",
"user" : "dbuser",
"db" : "db",
"roles" : [
{
"role" : "readWrite",
"db" : "db"
}
]
}
]
希望有做过这方面尝试的给予帮助 谢谢啦!
After searching online for a long time, I found that it is a mongoid bug mongoid
Then I tried to use the method here to solve it, but it still didn’t work. There was nothing I could do.
Fortunately, mongo can connect directly without authentication. Currently, this method can only be used.
I hope friends who have done it will reply after seeing it.