Have you ever faced problem of Access denied for user or any login related issues after re-installing MySQL server. I faced this issue and when I googled it, I saw many others are also suffering from this problem frequently. In this post, I will suggest you a good try which will solve this problem in 95% of cases.
Reason of Access denied Error
Access denied error for user ‘root’ problem occurs mostly when you un-install and install a new version or even previous version also. The problem lies in in-complete cleanup done by mysql uninstaller wizard. So, solution is also very simple, cleanup remaining junk manually.
You exception will look like this:
Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:910) at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3923) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1273) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031) at com.mysql.jdbc.ConnectionImpl.init(ConnectionImpl.java:718) at com.mysql.jdbc.JDBC4Connection.init(JDBC4Connection.java:46) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417) ... 5 more
Solution
Solution to access denied error is to remove old data folder from following location.
C:/Documents and Settings/All Users/Application Data/MySQL
[refer here]
This directory contains temp files and old DB data including your last login credentials used in previous installation. So, to solve this issue:
- Uninstall MYSQL server
- Remove everything from above folder
- Install a fresh MySQL server
You should be good to login in this in instance of Server.
Happy Learning !!
Comments