MySqlConnection myConn = new MySqlConnection("server=192.168.1.103;database=productcatalog;uid=root;password=12345678");
// where 192.168.1.103 is the PC's IP address.
above code does not give me any problem.
but when I have this:
MySqlConnection myConn = new MySqlConnection("server=localhost;database=productcatalog;uid=root;password=12345678");
it gives error: Unable to connect to any of the specified MySQL hosts.
I have thought that both the above statements are equivalent, are they not?
even when I uninstall MySQL and re-install again on this particular PC, it gives the same error.
However, when I test the above 2 statements with another PC, it does not give any error of such. I am puzzed what are the causes of the problem on that particular PC. Any hint? thanks.

2 answers
there might be a problem with the dns, try using 127.0.0.1 instead of localhost or check the System32\etc\drivers\hosts with notepad and check the dns of localhost.
answered 4 months ago by:
1351
476
thank you Muster, it helps.
Please check if you are using the correct port number.
answered 4 months ago by:
0