配置中配置账号和密码连接数据库,出现MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='zhupeng', source='ksc', password=<hidden>, mechanismProperties={}}权限异常

百度一下报错原因,看到了这条信息,

当然,这个提示等于没有提示,给我的感觉就是我少了某些东西,于是从设置账密的标签入手。点进标签,查看一下标签的定义。

        <xsd:attribute name="credentials" type="xsd:string" use="optional"><xsd:annotation><xsd:documentation><![CDATA[
The comma delimited list of username:password@database entries to use for authentication. Appending ?uri.authMechanism allows to specify the authentication challenge mechanism. If the credential you're trying to pass contains a comma itself, quote it with single quotes: '…'.]]></xsd:documentation></xsd:annotation></xsd:attribute></xsd:complexType>

其中有一段解释The comma delimited list of username:password@database entries to use for authentication. Appending ?uri.authMechanism allows to specify the authentication challenge mechanism. If the credential you're trying to pass contains a comma itself, quote it with single quotes: '…'.

这个格式是:username:password@database ,可能需要添加 ?uri.authMechanism权限(英语4级没有过,大致意思)。于是恍然大悟。原先从网上抄的写法是:

<mongo:mongo-client id="mongo" host="${mongo.host}" port="${mongo.port}"credentials="${mongo.username}:${mongo.password}@${mongo.dbname}">.......
</mongo:mongo-client>

查看xml配置,再结合翻译后的内容,发现就少了权限的问题,我通过用MongoDB数据库的工具看一下权限

添加权限后解决问题

<mongo:mongo-client id="mongo" host="${mongo.host}" port="${mongo.port}"credentials="${mongo.username}:${mongo.password}@${mongo.dbname}?authMechanism=SCRAM-SHA-1">....
</mongo:mongo-client>

Exception authenticating MongoCredential{mechanism=null, userName=‘zhupeng‘, source=‘ksc‘, password=相关推荐

  1. MongoDB查询报错:class com.mongodb.MongoSecurityException: Exception authenticating MongoCredential...

    异常日志: 2019-05-30 10:10:24,252 [http-nio-8080-exec-1] DEBUG [java.sql.Connection] - ooo Connection Op ...

  2. 【MongoDB异常】Exception authenticating MongoCredential解决方法

    我们通过ideal编辑器编辑 springboot时候,出现这个错误: com.mongodb.MongoSecurityException: Exception authenticating Mon ...

  3. UncategorizedMongoDbException: Exception authenticating MongoCredential解决办法

    今天通过springboot连接MongoDB的时候,出现了以下的报错: 从报错来看,是因为认证没有通过,检查了配置,是没有问题的,那么会不会是账号本身的问题呢? 于是到MongoDB的客户端看了下, ...

  4. 使用springBoot:run命令启动时报错:An exception occurred while running. null

    过程 详细报错信息如下: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.17.RELEASE ...

  5. nested exception is java.sql.SQLException: Data truncated for column 'PassWord' at row 72

    tomcat启动没有错误,进入登录界面发现登不进去,出现错误: 2016-08-17 14:52:44 -43568 [http-8080-4] DEBUG   - ==>  Preparing ...

  6. java getqueue 0_【求助】Exception in threadAWT-EventQueue-0java.lang.Null

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 用户登录 import java.awt.*; import java.awt.event.*; import javax.swing.*; import ...

  7. 错误HikariPool-1 - Exception during..+ Access denied for user ‘root‘@‘localhost‘ (using password: YES)

    项目场景: 前些天在IDEA中导入项目后,更改好配置,运行出错 问题描述 以下是错误提示: ERROR 18660 --- [3)-192.168.48.1] com.zaxxer.hikari.po ...

  8. Exception: java.io.IOException: Keystore was tampered with, or password was incorrect

    在进行证书相关操作默认密码changeit,而不是注册时自己设置的密码.

  9. go mongodb排序查询_Kotlin与MongoDB整合CURD案例详解

    1.mongodb的低版本bson无法转换类型 比如MongoDB数据库表的字段类型为Decimal,实体类用String去定义就会报如下错误 No converter found capablof ...

最新文章

  1. BOOKS STORE OPENCART 自适应主题模板 ABC-0093
  2. XMLHttpRequest Object
  3. 【推荐】微服务分布式企业框架Springmvc+mybatis+shiro+Dubbo+ZooKeeper+Redis
  4. 幼儿园计算机教案 妈妈的爱,幼儿园大班教案《妈妈的爱》(通用)
  5. python3.6+RF连接mysql
  6. 利用Fiddler模拟POST请求
  7. NOIP2016 D2T3 愤怒的小鸟
  8. gradle junit5_JUnit 5和Selenium –使用Gradle,JUnit 5和Jupiter Selenium设置项目
  9. www.how2j.com_HOW-TO:快速开始使用Spring 4.0,以构建简单的REST-Like API(演练)
  10. Seaborn——绘制统计图形
  11. Guns 删除功能_入门试炼07
  12. Java复习-对象的回收与垃圾的回收
  13. html的标签位置属性(学习笔记)
  14. 数据分析师的职业发展
  15. android 如何获取网络视频的第一帧
  16. java实现数据同步
  17. htmlcss全屏视频背景
  18. 10天学会英语常见词根后缀
  19. 【c语言】组件化打包—静态库lib
  20. 获取PNG图片的RGBA

热门文章

  1. html5画布绘制微信logo,HTML5新特性之用SVG绘制微信logo
  2. 【前端小项目】基于Vue全家桶的在线音乐播放器(提供在线演示)
  3. 吐槽大会4_郑云龙吐槽大会4第几期 郑云龙担任节目主咖吗
  4. Java学习笔记(未完成.....)
  5. 微信营销裂变应该如何做?
  6. 机器人视觉处理——视频回传
  7. J-Link仿真器与JTAG和SWD下载与接线
  8. linux下QT开发串口通信助手
  9. 自动套料软件Xsuper NEST——辽河重工专访
  10. 新型猪流感,人禽流感与普通流感的比较(视频)