SSM框架连接数据库出现这种问题

2019-01-02 20:25发布

2018 10:47:27 ERROR com.alibaba.druid.pool.DruidDataSource - create connection error
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:927)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1709)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1252)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2486)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2519)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2304)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.GeneratedConstructorAccessor18.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1375)
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1431)
at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:1844)

在其他电脑运行正常,导入后出现问题,不用框架连接数据库没问题,自己又建了一个新的项目也是SSM框架,结果也是这种问题,(即使数据库用户名不为root,它报错也是显示的Access denied for user 'root'@'localhost'),实在搞不懂,求大神指点

标签: java web
2条回答
十年一品温如言
2楼-- · 2019-01-02 20:36

是不是你服务器的mysql没有外部用户访问权限,或者防火墙的问题

查看更多
旧人旧事旧时光
3楼-- · 2019-01-02 21:03

是不是没有设置本机访问权限之类的。
grant select,insert,update,execute on table.* to 'root'@'localhost' identified by 'password';
grant select,insert,update,execute on table.* to 'root'@'127.0.0.1' identified by 'password';

查看更多
登录 后发表回答