Mysql Access Denied for User 'Xxx'@'Localhost' While Create Connection in Java

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:

6
Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article