Mongodb Production Environment Permission Issues

  mongodb, question

Rails+mongodb application, when deployed, added a user to the project database, gave readWrite permission, and then reported an error after being configured in Rails, saying that it did not have permission to obtain data, but it was possible to query data by logging in with this user in Mongo’s console.

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

I hope there are some people who have tried this aspect to help me, thank you!

After searching the internet for a long time, I found that it was a bug of mongoid.mongoid

Then try to use itHereThe way to solve once, still useless success, no way out.

Fortunately, mongo can connect directly without authentication. At present, only this method can be used.

I hope some friends who have done it will answer after seeing it.