简体   繁体   English

CannotGetMongoDbConnectionException:无法对数据库进行身份验证

[英]CannotGetMongoDbConnectionException: Failed to authenticate to database

In the replica-set Mongo Shell, use products;db.auth('worker'.'a*******6'); 在副本集Mongo Shell中, use products;db.auth('worker'.'a*******6'); is alright, but in spring-data-mongondb, I encountered the following problem: 没关系,但是在spring-data-mongondb中,我遇到了以下问题:

Exception in thread "main" org.springframework.data.mongodb.CannotGetMongoDbConnectionException: Failed to authenticate to database [products], username = [worker], password = [a*******6]
    at org.springframework.data.mongodb.core.ReflectiveDbInvoker.authenticate(ReflectiveDbInvoker.java:83)
    at org.springframework.data.mongodb.core.MongoDbUtils.doGetDB(MongoDbUtils.java:127)
    at org.springframework.data.mongodb.core.MongoDbUtils.getDB(MongoDbUtils.java:94)
    at org.springframework.data.mongodb.core.SimpleMongoDbFactory.getDb(SimpleMongoDbFactory.java:197)
    at org.springframework.data.mongodb.core.SimpleMongoDbFactory.getDb(SimpleMongoDbFactory.java:185)
    at org.springframework.data.mongodb.core.MongoTemplate.getDb(MongoTemplate.java:1595)
    at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:441)
    at org.springframework.data.mongodb.core.MongoTemplate.doCreateCollection(MongoTemplate.java:1612)
    at org.springframework.data.mongodb.core.MongoTemplate.createCollection(MongoTemplate.java:492)
    at com.qixin.appmarket.service.test.TestMongodb.main(TestMongodb.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Try updating to spring-data-mongodb to the latest version. 尝试将spring-data-mongodb更新到最新版本。 I was getting that authentication error while using version 1.7.2.RELEASE but it stopped after updating to 1.8.0.RELEASE . 我在使用1.7.2.RELEASE版本时遇到了身份验证错误,但在更新到1.8.0.RELEASE后它停止了。

In MongoDB , you can use: MongoDB ,您可以使用:

use products
db.createUser(
   {
     user: "accountUser",
     pwd: "password",
     roles: [ "readWrite", "dbAdmin" ]
   }
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Data MongoDB XML 配置无法针对 Mongo 数据库进行身份验证 - Spring Data MongoDB XML Configuration failed to Authenticate against Mongo-database 如何对数据库中的数据进行加密并重新使用以验证用户身份 - how to encrypt data in database and reuse it to authenticate users 使用mysql数据库对Spring安全性中的用户进行身份验证? - Using mysql database to authenticate users in Spring security? 从过滤器中的数据库验证用户是一个好习惯吗? - Is it a good practice to authenticate user from Database in Filter? 如何使用自己的数据库用户通过Spring Security和JWT进行身份验证 - How to authenticate with spring security and JWT with user of own database 通过Spring LDAP进行身份验证,并在数据库中进行其他安全性检查 - Authenticate via spring LDAP with additional security check in database Spring 和 Neo4j 数据库:无法验证用户 - Spring and Neo4j database: Can't authenticate user 使用 apache 骆驼通过 imap 连接到 ms 交换共享邮箱失败,并出现错误 AUTHENTICATE failed - Connecting to ms exchange shared mailbox via imaps using apache camel fails with error AUTHENTICATE failed STS数据库连接Ping失败 - STS Database Connection Ping Failed Spring 引导资源服务器与 JWT base64 编码 由于 Z1D1FADBD9150349C1357811 编码而无法进行身份验证 - Spring boot resource server with JWT base64 encoded Failed to authenticate since the JWT was invalid
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM