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 192.168.0.112)machine to the Vista (IP 192.168.0.110), 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 192.168.0.112 i have user with host 192.168.0.110 and likewise on IP 192.168.0.110 i have user with host 192.168.0.112.
Kindly assist on how to handle this and know that your help is much appreciated.

Recommended Answers

All 5 Replies

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'@'192.168.0.110' 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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.