解决:java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)

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

这些天刚学习MySQL,今天在MyEclipse下连接数据库,可是连接的代码检查了几遍,老师出现java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)的错误。


于是请教谷歌、百度。都说是密码错误,让改密码。。。。  可是明明密码就是没有错误的呀!

还有说是权限低,让改权限。查资料,权限也是最大的!!

试了下,无果。甚是郁闷!!于是搁置了,继续往下学习!

过了不少很久,一次偶然一瞥。哎,自己太马虎了! 看图。。。



原来是自己将user写成了uesr,简直太不仔细了。吸取教训!

仔细很重要呀!


转载请注明出处 http://blog.csdn.net/xn4545945

Access denied for user 'root'@'localhost' (using password Yes

09-25

08:43:20,125 WARN JDBCExceptionReporter:71 - SQL Error: 1045, SQLState: 28000rn08:43:20,140 ERROR JDBCExceptionReporter:72 - Access denied for user 'root'@'localhost' (using password: YES)rn08:43:20,140 WARN SettingsFactory:103 - Could not obtain connection metadatarnjava.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)rn at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2901)rn at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:773)rn at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3612)rn at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1204)rn at com.mysql.jdbc.Connection.createNewIO(Connection.java:1699)rn at com.mysql.jdbc.Connection.(Connection.java:408)rn at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:270)rn at java.sql.DriverManager.getConnection(DriverManager.java:582)rn at java.sql.DriverManager.getConnection(DriverManager.java:154)rn at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:291)rn at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:277)rn at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:259)rn at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:240)rn at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)rn at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)rn at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)rn at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)rn at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)rn at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)rn at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)rn at org.apache.catalina.core.StandardService.start(StandardService.java:525)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:595)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)rn非常蛋疼的问题,导入别人的项目时报这个错误。rn网上查了原因,无非三种:账户密码错误,权限不够,要么是架包,但我三种都试过了,还是报错。rn现贴下hibernate配置rn rn MySQL_JDBCrn rn rn jdbc:mysql://localhost:3306/db_eshop?useUnicode=true&characterEncoding=gb2312rn rn rootrn 123rn rn com.mysql.jdbc.Driverrn rn rn org.hibernate.dialect.MySQLDialectrn rn有哪位大侠能指正?

Access denied for user 'root'@'localhost' (using password: YES)

03-28

启动tomcat显示这个异常,但是可以用密码登陆数据库rn严重: Prototyperncom.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)rn at com.mysql.jdbc.Util.getInstance(Util.java:386)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)rn at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2238)rn at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2159)rn at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:792)rn at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)rn at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)rn at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)rn at java.sql.DriverManager.getConnection(DriverManager.java:582)rn at java.sql.DriverManager.getConnection(DriverManager.java:154)rn at org.logicalcobwebs.proxool.DefaultConnectionBuilder.buildConnection(DefaultConnectionBuilder.java:39)rn at org.logicalcobwebs.proxool.Prototyper.buildConnection(Prototyper.java:159)rn at org.logicalcobwebs.proxool.Prototyper.sweep(Prototyper.java:102)rn at org.logicalcobwebs.proxool.PrototyperThread.run(PrototyperThread.java:44)rnCaused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)rn at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)rn at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)rn at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:935)rn at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4101)rn at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1300)rn at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2337)rn at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2177)rn ... 16 morern2014-3-28 13:57:26 org.logicalcobwebs.proxool.no2class_log sweeprn严重: Prototyperncom.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)rn at com.mysql.jdbc.Util.getInstance(Util.java:386)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)rn at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2238)rn at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2159)rn at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:792)rn at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)rn at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)rn at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)rn at java.sql.DriverManager.getConnection(DriverManager.java:582)rn at java.sql.DriverManager.getConnection(DriverManager.java:154)rn at org.logicalcobwebs.proxool.DefaultConnectionBuilder.buildConnection(DefaultConnectionBuilder.java:39)rn at org.logicalcobwebs.proxool.Prototyper.buildConnection(Prototyper.java:159)rn at org.logicalcobwebs.proxool.Prototyper.sweep(Prototyper.java:102)rn at org.logicalcobwebs.proxool.PrototyperThread.run(PrototyperThread.java:44)rnCaused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)rn at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)rn at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)rn at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:935)rn at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4101)rn at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1300)rn at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2337)rn at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2177)rn ... 16 morern

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试