Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i have two machine PC#1 with db mysql and appache and PC#2 with a c# form try to connect to this db

here is my connection string used in PC#2: SERVER=My_public_ip;DATABASE = my_test; UID = root; PASSWORD = xxxx;"

when i try to connect locally from PC#1 it work good:

SERVER=localhost;DATABASE = my_test; UID = root; PASSWORD = xxxx;"

when i try

i did make my root user remote enabled like that:

GRANT ALL ON *.* to '%'@'%' WITH GRANT OPTION;

and all i get is an Event viewer: unable to connect to any of the specified MySQL host

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
185 views
Welcome To Ask or Share your Answers For Others

1 Answer

If both MySql installation are similar (no port changes etc.) then you might want to check connection restriction to the port that MySQL is listening to (usually 3306) on the remote machine. A firewall or something of that sort may be preventing access.

Also if I may ask, have you used any other tool(like MySQL WorkBench or similar) to connect to the MySQL on the remote machine, from the machine which is running your c# form.

That may give you an idea as to whether it access restrictions.

Lastly, i suggest you specify the port in the connection string.

"Data Source =SomeName; Database=SomeDb; User Id=SomeUserId; Password=SomePassword; Port=3306;"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...