Hi guys.
I have previously been developing a Java application using 2 Windows Vista PCs that both have MySQL as the database. I have always created a user for each PC (specifying their IPs as allowed hosts to connect) on the other and then in the application the code for connecting to the database has the IP part as a variable as follows:

//some other code
public Connection getCon(String localip)
//some other code
String url = "jdbc:mysql://"+localip+"/dbEMPLOYEE";
//some other code with other connection parameters

Now, this has always worked for me with 2 Windows Vista machines.

My problem started when I started using a Windows 7 PC instead of a Windows Vista one, on one end while still maintaining the other Windows Vista machine.
The message I now keep getting whenever I change the IP to point from the Windows 7 (IP to the Vista (IP, is as follows:

java.sql.SQLException: null,  message from server: "Host 'dangari-PC' is not allowed to connect to this MySQL server"

It's as if it is just seeing the Host name and not the passed IP!
Mind you I have the user in both MySQL servers set with the other machine's IP such as:
on IP i have user with host and likewise on IP i have user with host
Kindly assist on how to handle this and know that your help is much appreciated.

7 Years
Discussion Span
Last Post by masijade

Read the user management portion of the MySQL documentation and pay close attention to the "GRANTS" portion of it.


Read the user management portion of the MySQL documentation and pay close attention to the "GRANTS" portion of it.

My GRANT command for creating the user is as follows:

GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'' IDENTIFIED BY 'mysql123456';

Which has always worked when both machines had Vista, but now since one machine has Windows 7..it doesn't connect thus giving the above error.

Is there anything that I'm leaving out as regards Windows 7?


Ask microsoft/MySQL? In any case, not a Java question.

When I connect directly via MySQL, it connects from the Windows 7 PC to the Vista one without a hitch! This is what is baffling me really. Question on my mind is "Could this be related to the database driver I've used or something?".

Thanks anyway masijade for your help.


That, then, would be a MySQL question (they write the JDBC Driver). But if you use the IP address and the server gets the hostname (as that message implies) and it cannot, or is unable, to resolve that name to the "proper" ip, then, of course, your grant won't work.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.