Reputation: 2454
I have a Spring Boot application which throws the below exception when lauching. The strange thing is the same jar (when run from windows and Ubuntu) works with a fresh install of MySQL 5.7 on Windows but does NOT work on MySQL 5.6 on Ubuntu 14 lts and throws the below exception!
The root privileges, passwords are exactly the same. I tried with fresh installs on MySQL on Windows and Ubuntu. I am clueless at this point - I have tried steps in answers similar to this question on SO, but nothing works.
Is it likely an issue with mysql versions? What am I possibly missing?
EVERE: Unable to create initial connections of pool.
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password : YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3966)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3902)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:875)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(My sqlIO.java:1712)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1228)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2 284)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:806)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct orAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC onstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java :328)
Upvotes: 1
Views: 5451
Reputation: 108370
The error message from MySQL is this part:
Access denied for user 'root'@'localhost' (using password: YES)
That's a standard error message when either the User/Host doesn't exist or has a different password (or supplying a password when one is not required.) The standard troubleshooting for that MySQL error apply. That MySQL error indicates what the problem is.
You claim that the "root privileges, passwords are exactly the same".
If that's true, then there's a difference in the configuration of the connection pool.
I'd check the values of the "User", "Host" and "Password" columns in the mysql.user
table. Also verify that the plugin column contains 'mysql_native_password'
.
Is there a row with values 'root'
and 'localhost'
? (A user in MySQL is identified by the combination of "User" and "Host".)
Does the password hash for that user match? (Compare the hash returned from a query to the one stored in the mysql.user table ... SELECT PASSWORD('mysupersecret')
)
If changes were made to the mysql.user
table with DML operations, was a FLUSH PRIVILEGES
statement executed to force MySQL server to re-read the grant tables?
These are just some guidelines. There's not enough information provided to accurately diagnose the problem.
https://dev.mysql.com/doc/refman/5.7/en/problems-connecting.html
A very common error is to insert a new row with Host='%' and User='some_user', thinking that this enables you to specify localhost to connect from the same machine. The reason that this does not work is that the default privileges include a row with Host='localhost' and User=''. Because that row has a Host value 'localhost' that is more specific than '%', it is used in preference to the new row when connecting from localhost! The correct procedure is to insert a second row with Host='localhost' and User='some_user', or to delete the row with Host='localhost' and User=''. After deleting the row, remember to issue a FLUSH PRIVILEGES statement to reload the grant tables.
I strongly recommend you consider creating a user other than root
for your application, following the best practice security principle of least privilege.
Upvotes: 4