标签:... mat 出现 min xxxxxx bow modified users odi
由于3.0.3,mongodb加入了SCRAM-SHA-1校验方式,需要第三方工具配合进行验证,所有Spring boot连接MongoDB时会出现用户认证失败。
解决方法:
> use admin switched to db admin > var schema = db.system.version.findOne({"_id" : "authSchema"}) > schema.currentVersion = 3 3 > db.system.version.save(schema) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
删除原来创建的已经使用了SCRAM-SHA-1认证方式的用户
> use admin switched to db admin > db.system.users.find() [...] { "_id" : "userdb.myuser", "user" : "myuser", "db" : "userdb", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : 10000, "salt" : "XXXXXXXXXXXXXXXXXXXXXXXX", "storedKey" : "XXXXXXXXXXXXXXXXXXXXXXXXXXX", "serverKey" : "XXXXXXXXXXXXXXXXXXXXXXXXXXX" } }, "roles" : [ { "role" : "dbOwner", "db" : "userdb" } ] }
> use userdb switched to db userdb > db.dropUser("myuser") true >db.createUser({user:‘myuser‘,pwd:‘123456‘,roles:[{role:‘dbOwner‘,db:‘userdb‘}]})
然后关闭服务器,开启认证,重启服务器!!
Spring boot连接3.03以上的mongodb 权限验证问题
标签:... mat 出现 min xxxxxx bow modified users odi
原文地址:https://www.cnblogs.com/guxia/p/9107981.html