为了账号安全,请及时绑定邮箱和手机立即绑定

项目启动成功后,浏览器访问报java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)

2019-02-15 16:23:06.230 ERROR 14604 --- [eate-1204953090] com.alibaba.druid.pool.DruidDataSource   : create connection error, url: jdbc:mysql://127.0.0.1:3306/dianshang, errorCode 1045, state 28000


java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:928) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1750) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1290) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2502) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2535) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2320) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46) ~[mysql-connector-java-5.1.29.jar:na]

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_92]

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_92]

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_92]

at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_92]

at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416) ~[mysql-connector-java-5.1.29.jar:na]

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347) ~[mysql-connector-java-5.1.29.jar:na]

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1464) ~[druid-1.1.3.jar:1.1.3]

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1529) ~[druid-1.1.3.jar:1.1.3]

at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2239) ~[druid-1.1.3.jar:1.1.3]


使用generator可以自动生成文件,但启动项目成功后,使用浏览器访问报上面的错误。。。。

正在回答

1 回答

SpringBoot项目配置文件有两种格式,常用的application-xx.properties和最新的application-xx.yml。 
运行项目时常常出现以上错误。一般是两个原因导致的:要么是连接信息配置错误,要么就是数据库未授权。

localhost改成%

https://img1.sycdn.imooc.com//5cd5254800010ff304690070.jpg

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

项目启动成功后,浏览器访问报java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信