Ramesh J
Ramesh J

Reputation: 824

Access denied for user 'user_name'@'localhost' (using password: YES) in java

I have installed MYSQL DataBase in my machine, and have java code to manipulate the data.

Database credentials... Database Name:ram username: "user_name" password : "123". host is: localhost;

I gave ALL PRIVILEGES to this "user_name" user (like create, update,delete nd etc..)

Now i want to connect with Database we use the following method

DriverManager.getConnection("jdbc:MySql://localhost/ram","user_name","123");

Well its working correctly.

Now i changed the user credentials as Host: 127.0.0.1

and replace the connection syntax as DriverManager.getConnection("jdbc:MySql://127.0.0.1/ram","Ramesh","123");

Good,, its working fine .. Now i want to connect to DB with any host for this user. so i change the user details as Host:%

used the following method to connect with DB

DriverManager.getConnection("jdbc:MySql://127.0.0.1/ram","Ramesh","123");

but it gives an error like

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

I can't decide this problem which belongs to either java code or DB code.

Please let me out from this one guys...Thanks in advnce...

Upvotes: 0

Views: 3547

Answers (1)

Aviram
Aviram

Reputation: 553

you need do FLUSH PRIVILEGES; after you changes to % to make those changes take affect

Upvotes: 1

Related Questions