M BUZZ CRAZE NEWS
// news

MySQL Access denied for user 'xxx'@'localhost' while create connection in Java

By Joseph Russell

There are user 'pawa' on my Ubuntu. When I try create Connection object with code:

Properties properties = new Properties();
properties.put("user", "root");
properties.put("password", "password");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/library_db@localhost");

I get error like:

Caused by: java.sql.SQLException: Access denied for user 'pawa'@'localhost' (using password: NO)

I dont understand why my user appear here? In properties I put root user. I give all permission to my user with

GRANT ALL PRIVILEGES ON library_db.* TO 'pawa'@'localhost';
FLUSH PRIVILEGES;

but it doesnt work.


Edit to include screenshots supplied in comments:

Primary User Account

Root User Account

6 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy