c# - 无法在 C# 中使用静态 IP 地址 + 端口连接到数据库

标签 c# mysql phpmyadmin port

我有一个连接到 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/

相关文章:

mysql - 检查 2 列是否重复

mysql - 将 MySQL 迁移到 Parse.com 的最佳方式是什么

mysql - 通过 phpMyAdmin SQL 控制台插入日期失败

c# - 文件流 - 文件名、目录名或卷标语法不正确

c# - 使用 NetTopologySuite 将东距/北距转换为纬度/经度

mysql - SQL查询有不同的结果

PHP插入到mysql

MySQL - 错误 #1064 - 删除记录 phpmyadmin

c# - 在扩展方法中使用 .net core 依赖项

c# - 将文件从字符串或流上传到 FTP 服务器