springboot使用mongoTmeplate操作出现权限不足问题
错误提示:
Command failed with error 13 (Unauthorized): ‘command insert requires authentication’ on server 122.51.240.229:27017. The full response is {“ok”: 0.0, “errmsg”: “command insert requires authentication”, “code”: 13, “codeName”: “Unauthorized”}; nested exception is com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): ‘command insert requires authentication’ on server 122.51.240.229:27017. The full response is {“ok”: 0.0, “errmsg”: “command insert requires authentication”, “code”: 13, “codeName”: “Unauthorized”}
问题背景:
由于我们的Mongod服务部署在某云上,未设置登录权限导致我们的数据被人挟持,只好删库将数据回滚并修改配置文件启动登录权限校验。但是自从开启后,后台服务操作mongodb疯狂报错。
spring-boot-starter-data-mongodb v2.2.2.RELEASE
配置截图:
解决:
配置application.yml的mongod配置
spring:
data:
mongodb:
uri: mongodb://test:test@199.151.240.229:27017/testdb