我有一个连接到 MySQL 数据库的现有应用程序(使用 WampServer)。我可以使用 localhost
作为我的服务器的名称。
我尝试使用静态 IP 地址代替 localhost
。可以从 http://192.168.1.1:1234/phpmyadmin
访问数据库。
我已经这样设置了我的 app.config:
<appSettings>
<add key="MyConnection" value="Data Source=192.168.1.1;Port=1234;Database=mydb;UID=root;" />
</appSettings>
但是当我尝试运行应用程序时收到错误:
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
有什么建议吗?
最佳答案
默认情况下,phpmyadmin 监听本地主机 (127.0.0.1)。你必须修改配置文件来监听 0.0.0.0
或者只是在/etc/my.cnf 中注释这一行:
#bind-address = 127.0.0.1
然后重启你的mysql服务器
关于c# - 无法在 C# 中使用静态 IP 地址 + 端口连接到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20341851/