解决springBoot启动报错Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required

Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required
意思是获取JDBC连接失败,导致的原因是这个: CLIENT_PLUGIN_AUTH is required,翻译一下意为:客户端插件验证是必需的
所以大概我们能看出来是和我们电脑上的mysql有关
想一下springBoot使用的mysql版本是多少,如果我们没有指定它是使用最新的版本,但是我们电脑自己的mysql可能不是最新的。我电脑上就是mysql5,而springBoot默认配置的不是,所以版本不同导致了问题
所以解决办法就是在添加依赖时手动指定mysql版本

这样再启动就没有问题了。
另外要注意自己的配置文件

spring:
  datasource:
    #mysql5版本的url为下面这样
    url: jdbc:mysql://localhost:3306/mybatisplus?characterEncoding=utf-8&useSSL=false
    #mysql8的是这样(多了时区的设置):
#    url: jdbc:mysql://localhost:3306/mybatisplus?serverTimezone=CST&characterEncoding=utf-8&useSSL=false
    username: root
    password: 123
    #mysql5的驱动是这样
    driver-class-name: com.mysql.jdbc.Driver
    #springBoot2.1开始就内置jdbc8驱动了,所以要用驱动是:com.mysql.cj.jdbc.Driver

如果不想看到springBoot那么多info日志的输出,我们可以配置一下日志级别

logging:
  level:
    root: error
posted @   程长新  阅读(8842)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
点击右上角即可分享
微信分享提示