问题
I am trying make a connection to MySQL from my java application and it keeps on saying :
java.sql.SQLException: Access denied for user \'vincent\'@\'x.x.x.x\' (using password: YES)
I have checked in phpmyadmin that vincent can conect from any host and I also have a python script who can connect with the same username/password without any problem
What is the problem ?
Thank you very much
Regards.
回答1:
Try granting all privileges to your user from any machine in mysql:
grant all on db_name.* to ‘vincent’@'%';
where db_name is your database name ...
回答2:
Here's how I'd GRANT permissions:
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';
You need the user's host machine as well.
回答3:
Use this
GRANT ALL PRIVILEGES ON db_base.* TO db_user @'%' IDENTIFIED BY 'db_passwd';
You have to give access to user on db. and yes if you are being using a user defined stored procedure and function then also use
GRANT SELECT ON mysql.proc TO 'db_user'@'%';
回答4:
You have to specify the userid
and password
while getting connection object:
Connection cn=DriverManager.getConnection("protocol","userid","password");
来源:https://stackoverflow.com/questions/8224898/java-jdbc-access-denied-for-user