Here I have this error

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

if I execute this thing

GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' IDENTIFIED BY 'root' WITH GRANT OPTION;

then I have this error.

ERROR 1045 (28000): Access denied for user ''@'localhost' (using password: NO)

ok, I had this exact problem last week. What you need to do is to remove the anonymous users that the mySQL installer creates.
For whatever reason all attempts to log in get mapped to that user, causing their logins to fail as is has no permissions to do anything.

Easiest with mysql workbench, but drop user ''@'localhost'; and the same for the other anonymous users works as well from the commandline client if you can get into that.

You may look at this post which may help resolving your issue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.