一次无语的Exception

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/coding_zhao/article/details/79083910

Access denied for user ”@’localhost’ (using password: No)

昨天做springboot开发搭建环境的时候一运行就报这错误,一看以为是密码的问题,改了一波数据库密码,反过来试还是不行,然后以为是数据库驱动的问题,换了版本的驱动还是不对,最后上网百度一波,网上众说纷纭,大致是数据库权限问题,又胡乱搞了一波,整得我都忘记了原本得数据库密码,又重装了一波数据库,今天早上一到公司,又搞半个小时,我又不得不重头来看这个配置,突然我用之前写的一个SSH项目连接了一下数据库,完全没得问题,我一下明白,这个不是数据库的原因,是配置的原因,我又拿出我之前写的一个springboot项目,看了下配置,欲哭无泪,细微差别浪费了我一下午的功夫,这是我之前写的配置:

spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.data-username=root
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xunwu?characterEncoding=UTF8&useSSL=false
spring.datasource.data-password=12345
spring.jpa.show-sql=true
spring.session.store-type=hash_map
### 这个是之后的代码
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=12345
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xunwu?characterEncoding=UTF8&useSSL=false
spring.jpa.show-sql=true
spring.session.store-type=hash_map

原来是idea自动提醒惹的祸,自己就加上了data-,导致我一直连不上数据库,将spring.datasource.data-username=root修改为spring.datasource.username=root就对了,如果出现类似,using password yes or no 的问题多半就是 name password url 端口 表名的问题。

猜你喜欢

转载自blog.csdn.net/coding_zhao/article/details/79083910