remote connection to mysql

泄露秘密 提交于 2019-12-12 07:01:29

问题


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


回答1:


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;"



来源:https://stackoverflow.com/questions/22687358/remote-connection-to-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!