用户拒绝Java JDBC访问

我正在尝试从我的java应用程序连接MySQL,它继续说:

java.sql.SQLException:用户’vincent’@’xxxx’拒绝访问(使用密码:YES)

我已经检查过phpmyadmin,vincent可以从任何主机进行连接,而且我还有一个python脚本,可以使用相同的用户名/密码连接而没有任何问题

问题是什么 ?

非常感谢你

问候。

尝试从mysql中的任何计算机向用户授予所有权限:

  grant all on db_name.* to 'vincent'@'%'; 

其中db_name是您的数据库名称…

这是我的GRANT权限:

 create database foobar; create user foobar identified by 'foobar'; grant all on foobar.* to 'foobar'@'%' identified by 'foobar'; grant all on foobar.* to 'foobar'@'localhost' identified by 'foobar'; 

您还需要用户的主机。

用这个

 GRANT ALL PRIVILEGES ON db_base.* TO db_user @'%' IDENTIFIED BY 'db_passwd'; 

您必须在db上授予用户访问权限。 是的,如果您正在使用用户定义的存储过程和function,那么也使用

 GRANT SELECT ON mysql.proc TO 'db_user'@'%'; 

获取连接对象时必须指定useridpassword

 Connection cn=DriverManager.getConnection("protocol","userid","password");