blah blah blah is here! blah blah » Close

up0down
link

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.

last answered 4 months ago

2 answers

link

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.

thank you Muster, it helps.

up0down
link

Please check if you are using the correct port number.

Feedback