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

大兔子大兔子 提交于 2019-12-13 06:26:19

问题


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.


回答1:


Try granting the privileges:-

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

-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION; 


来源:https://stackoverflow.com/questions/16880877/access-denied-for-user-userlocalhost-using-password-yes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!