java.sql.SQLException: Access denied for user ‘root’@’localhost’ (using password: YES)


Samebug tips1

MySQL doesn't support some types of characters (such as emojis) with the utf8 encoding. You need to be on MySQL 5.5+ and force utf8mb4 (everywhere, client and server). You can do this sending the query "SET NAMES utf8mb4". Check this https://goo.gl/3E2qzg


7 months ago
Expert tip

Solutions on the web651

Solution icon of web
via wordpress.com by Unknown author, 1 year ago
Access denied for userroot’@’localhost’ (using password: YES)

Solution icon of web
via atomikos.com by Unknown author, 1 year ago
Access denied for user 'root@localhost'@'localhost' (using password: YES)

Solution icon of web
Access denied for user 'root@localhost'@'localhost' (using password: YES)

Solution icon of stackoverflow
Access denied for user 'root@localhost'@'localhost' (using password: YES)

Solution icon of coderanch
via Coderanch by Migrated From Jforum.net, 9 months ago
Access denied for user 'root'@'localhost' (using password: YES)

Solution icon of github
Access denied for user 'root'@'localhost' (using password: YES)

Solution icon of github
Access denied for user 'root'@'localhost' (using password: YES)

Solution icon of github
via GitHub by sajeetharan
, 1 year ago
Access denied for user 'root'@'localhost' (using password: YES)

Solution icon of sourceforge
via opencrx by timvand
, 1 year ago
Access denied for user 'root'@'localhost' (using password: YES)

Solution icon of stackoverflow
Access denied for user 'root'@'localhost' (using password: YES)

Stack trace

java.sql.SQLException: Access denied for user ‘root’@’localhost’ (using password: YES)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:931)
	at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4031)
	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1296)
	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2338)
	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
	at java.sql.DriverManager.getConnection(DriverManager.java:620)
	at java.sql.DriverManager.getConnection(DriverManager.java:200)
	at JDBCTest.main(JDBCTest.java:14)

Write tip

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

Users with the same issue

Once, 2 weeks ago
Once, 3 months ago
Once, 4 months ago
3 times, 11 months ago
6 times, 1 year ago
161 more bugmates