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

刚安装的mysql,在项目运行时出现
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)


信息如下:

09:58:53,666 |-WARN in ch.qos.logback.core.db.DriverManagerConnectionSource@298f8601 - Could not discover the dialect to use. java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
	at java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
	at 	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998)
	at 	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835)
	at 	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771)
	at 	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:870)
	at 	at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1659)
	at 	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)
	at 	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2239)
	at 	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2270)
	at 	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2069)
	at 	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
	at 	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
	at 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at 	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at 	at com.mysql.jdbc.Util.handleNewInstance(Util.java:389)
	at 	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
	at 	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
	at 	at java.sql.DriverManager.getConnection(Unknown Source)
	at 	at java.sql.DriverManager.getConnection(Unknown Source)
	at 	at ch.qos.logback.core.db.DriverManagerConnectionSource.getConnection(DriverManagerConnectionSource.java:54)
	at 	at ch.qos.logback.core.db.ConnectionSourceBase.discoverConnectionProperties(ConnectionSourceBase.java:48)
	at 	at ch.qos.logback.core.db.DriverManagerConnectionSource.start(DriverManagerConnectionSource.java:38)
	at 	at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:167)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)
	at 	at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:49)
	at 	at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
	at 	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
	at 	at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
	at 	at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
	at 	at ch.qos.logback.ext.spring.LogbackConfigurer.initLogging(Unknown Source)
	at 	at ch.qos.logback.ext.spring.web.WebLogbackConfigurer.initLogging(Unknown Source)
	at 	at ch.qos.logback.ext.spring.web.LogbackConfigListener.contextInitialized(Unknown Source)
	at 	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4772)
	at 	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
	at 	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at 	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
	at 	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
	at 	at java.util.concurrent.FutureTask.run(Unknown Source)
	at 	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at 	at java.lang.Thread.run(Unknown Source)
09:58:53,671 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@25:15 - RuntimeException in Action for tag [appender] java.lang.IllegalStateException: DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect
	at java.lang.IllegalStateException: DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect
	at 	at ch.qos.logback.core.db.DBAppenderBase.start(DBAppenderBase.java:62)
	at 	at ch.qos.logback.classic.db.DBAppender.start(DBAppender.java:93)
	at 	at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:96)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196)
	at 	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)
	at 	at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99)
	at 	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:49)
	at 	at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
	at 	at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
	at 	at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
	at 	at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
	at 	at ch.qos.logback.ext.spring.LogbackConfigurer.initLogging(Unknown Source)
	at 	at ch.qos.logback.ext.spring.web.WebLogbackConfigurer.initLogging(Unknown Source)
	at 	at ch.qos.logback.ext.spring.web.LogbackConfigListener.contextInitialized(Unknown Source)
	at 	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4772)
	at 	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
	at 	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at 	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
	at 	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
	at 	at java.util.concurrent.FutureTask.run(Unknown Source)
	at 	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at 	at java.lan八月 11, 2017 9:58:53 上午 org.apache.catalina.core.ApplicationContext log
信息: JUL to SLF4J bridge is not available on the classpath
g.Thread.run(Unknown Source)


然后打开sql文件中的mysql.exe也是闪退,在小黑框中打开mysql,也报错误: “Access denied for user 'ODBC'@'localhost' (using password:NO)”

网上搜了一下解决方案

在Mysql目录下my.ini文件中,最后一行添加“skip-grant-tables”,保存并关闭文件。

重启mysql服务,再执行。

问题解决!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值