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

可紊 提交于 2020-11-26 08:40:35
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:871)
    at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1714)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1224)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2190)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2221)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2016)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    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:425)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at com.baomidou.mybatisplus.generator.config.DataSourceConfig.getConn(DataSourceConfig.java:191)
    at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.handlerDataSource(ConfigBuilder.java:269)
    at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.<init>(ConfigBuilder.java:132)
    at com.baomidou.mybatisplus.generator.AutoGenerator.execute(AutoGenerator.java:92)
    at com.nums.industry5.MyGenerator.main(MyGenerator.java:135)
Exception in thread "main" java.lang.NullPointerException
    at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.getTablesInfo(ConfigBuilder.java:457)
    at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.handlerStrategy(ConfigBuilder.java:281)
    at com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder.<init>(ConfigBuilder.java:142)
    at com.baomidou.mybatisplus.generator.AutoGenerator.execute(AutoGenerator.java:92)
    at com.nums.industry5.MyGenerator.main(MyGenerator.java:135)

这是在运行代码的过程中将一个sql语句执行错误,然后自己失去了登录权限.

当时解决这个bug也是找了挺多的地方的.

后来发现只有这种方法是最好的:

打开你安装mysql数据库的地方,然后在my.ini这个文件中最后一行配置上这句话,

skip-grant-tables

然后将mysql这个服务进行重新启动.通过我的电脑--->管理---->服务---->>>找到mysql,进行重新启动.然后再重新进行登录就可以登录.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!