启动Spring后,连接mysql报错

  1. 连接失败,原因是Mysql服务未启动

解决方法:启动mysql服务

  方法一:

  • 以管理员身份运行CMD
  • 输入命令:net start mysql

  方法二:

  • 右键计算机-管理-服务和应用程序-服务
  • 右键启动Mysql服务

  1. 配置的密码正确,但提示拒绝访问:

   解决方法:配置文件中加入SSL=Fasle

spring.datasource.url=jdbc:mysql://localhost:3306/sampledb?useUnicode=true&characterEncoding=utf-8&useSSL=false
  1. 提示java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed

 解释方法:

&allowPublicKeyRetrieval=true
spring.datasource.url=jdbc:mysql://localhost:3306/sambledb?useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true&useSSL=false
原文地址:https://www.cnblogs.com/pandaly/p/11765947.html