springboot使用mongoTmeplate操作出现权限不足问题

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服务启用安全校验

解决:

配置application.yml的mongod配置

spring:
  data:
    mongodb:
      uri: mongodb://test:test@199.151.240.229:27017/testdb
文档参考:

springboot集成mongoDB需要认证

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值