ruby-on-rails - Mongodb 生产环境权限问题
过去多啦不再A梦
过去多啦不再A梦 2017-04-25 09:02:19
0
1
520

Rails + Mongodb 应用,部署的时候为项目数据库添加了一个用户,给了 readWrite 权限,然后在rails中配置好之后报错,说是没有权限获取数据,但是在mongo的控制台用该用户登录是可以查询数据的。

mongoid.yml

ymlproduction:
  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"
            }
        ]
    }
]

希望有做过这方面尝试的给予帮助 谢谢啦!

过去多啦不再A梦
过去多啦不再A梦

reply all(1)
仅有的幸福

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template