【bug】org.springframework.data.mongodb.UncategorizedMongoDbException: Exception authenticating MongoC

场景:

  • navicat 创建monogdb库 名称为 hzd
  • spring boot 连接hzd 报错

报错:

org.springframework.data.mongodb.UncategorizedMongoDbException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='root', source='hzd', password=<hidden>, mechanismProperties=<hidden>}

 原因:

        创建集合后,需要账号,密码,并赋予读写权限

  • 账号:root
  • 密码:xxxxxxxx
db.createUser({user: "root",pwd: "XXXXXXXX",roles: [ { role: "readWrite", db: "hzd" } ]} )

posted @ 2022-11-16 18:18  随风落木  阅读(50)  评论(0编辑  收藏  举报  来源