登录Mysql过程中,提示 errorCode 1045, state 28000
1 2
| create connection SQLException, url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false, errorCode 1045, state 28000 java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
|
仔细检查application.yml,发现用户名、密码均正确,无空格,但是还是报错
1 2 3 4 5 6 7 8 9 10
| spring: application: name: cloud-payment-service datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: org.gjt.mm.mysql.Driver url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false username: root password: 0000
|
到网上检索原因,最后在https://www.cnblogs.com/st-client/p/11432881.html
找到解决方法:
给0000加个单引号变为’0000’则登陆成功,根本原因还是因为密码错误。
1 2 3 4 5 6
| type: com.alibaba.druid.pool.DruidDataSource driver-class-name: org.gjt.mm.mysql.Driver url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false username: root password: '0000'
|
yml文件上对于纯数字类型的密码需要加引号,如果是包含字母的就不需要。