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

来源:2-4 Mybatis自动生成器使用方式

qq_淡忘_51

2019-02-15 16:26

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回答

  • Heely8023
    2019-05-10 15:16:54

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

    localhost改成%

    https://img4.mukewang.com/5cd5254800010ff304690070.jpg

SpringBoot构建电商基础秒杀项目

应用SpringBoot快速搭建拥有用户、商品、交易及秒杀活动的电商秒杀应用。

49066 学习 · 954 问题

查看课程

相似问题