Access denied for 'root'@'localhost' using Password=YES

时间:2015-08-07 01:45:16

标签: java mysql

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

0 个答案:

没有答案