远程连接到mysql [英] remote connection to mysql

查看:63
本文介绍了远程连接到mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两台机器带有 db mysqlappache 的 PC#1 和带有 c# 形式的 PC#2 尝试连接到这个数据库

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

这是我在 PC#2 中使用的连接字符串:SERVER=My_public_ip;DATABASE = my_test;UID = 根;密码 = xxxx;"

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

当我尝试从 PC#1 本地连接时,它运行良好:

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

SERVER=localhost;DATABASE = my_test;UID = 根;密码 = xxxx;"

当我尝试

我确实像这样启用了我的 root 用户远程:

i did make my root user remote enabled like that:

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

我得到的只是一个事件查看器:无法连接到任何指定的 MySQL 主机

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

推荐答案

如果两个 MySql 安装相似(没有端口更改等),那么您可能需要检查 MySQL 正在侦听的端口的连接限制(通常是 3306)在远程机器上.防火墙或类似的东西可能会阻止访问.

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.

另外,如果我可能会问,您是否使用任何其他工具(如 MySQL WorkBench 或类似工具)从运行您的 c# 表单的机器连接到远程机器上的 MySQL.

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.

数据源=SomeName;数据库=SomeDb;用户ID=SomeUserId;密码=SomePassword;端口=3306;"

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

这篇关于远程连接到mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆