mongodb 报错:Authentication failed 问题
问题:连接数据库时报错com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName=‘root’, source=‘gateway’, password=, mechanismProperties=} Command failed with e
·
问题:
连接数据库时报错
com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName=‘root’, source=‘gateway’, password=, mechanismProperties=} Command failed with error 18 (AuthenticationFailed): ‘Authentication failed.’ on server 192.168.81.13:27017. The full response is {“ok”: 0.0, “errmsg”: “Authentication failed.”, “code”: 18, “codeName”: “AuthenticationFailed”}.
解决
连接uri
mongodb://user:password@host:port/dbname
增加参数 authSource
例如:
mongodb://user:password@host:port/dbname?authSource=admin
一般情况下authSource是admin,根据需要替换
更多推荐
已为社区贡献1条内容
所有评论(0)