Вопрос

I'd found too many questions related to this problem still I'm having the same problem.

I've installed MySQL Server from MYSQL::Download MYSQL Installer. Also, I've running xampp on my localhost.

http://localhost/phpmyadmin and MySQL Command Line Client are working fine and I'm able to login as well as execute SQL queries. But the problem is, if I'm using jdbc to connect to MySQL then the error comes Access denied for 'root'@'localhost' (using password:yes).
The connection string I'm using for jdbc is

DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "root", "root");

but it's not working. I tried removing the port number (3306), still the same problem.
I also tried to start MySQL Workbench installed with the installer and getting the same error for connection.

If anybody could help? phpmyadmin working fine and I'm able to run sql queries from a php program. But its not working fine with java.

Это было полезно?

Решение

Try granting the privileges:-

 mysql> GRANT ALL PRIVILEGES ON *. * TO root@localhost

-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION; 
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top