0

I am trying to log into mysql though java with a .jar file I am running on the server. And here is my code, but I keep coming up with this error

Access denied for user 'root'@'localhost' (using password: YES)

I have read a bunch of answers for this on SO and such but nothing has worked for me. I am trying to log in as root on the localhost. Here is code

String myDriver = "com.mysql.jdbc.Driver";
      String myUrl = "jdbc:mysql://localhost/db";
      Class.forName(myDriver);
      Connection conn = DriverManager.getConnection(myUrl, "root", "myPassword");

I have tried this

mysql -uroot

But then get Access denied for user 'root'@'localhost' (using password: NO) but when I run the .jar file I get Access denied for user 'root'@'localhost' (using password: YES)

Thanks

spen123
  • 3,464
  • 11
  • 39
  • 52
  • http://stackoverflow.com/questions/2995054/access-denied-for-user-rootlocalhost-using-passwordno – Tharif Aug 07 '15 at 01:49
  • @utility I have tried that its not working – spen123 Aug 07 '15 at 01:55
  • @spen123 What means 'all this'? `--skip-grant-tables` always works. With this option (on mysql**d**) you are able to login with and without password. Then you have a chance to fix your permissions table – Daniel Alder Aug 24 '15 at 09:21

0 Answers0