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