【问题标题】:Connection to MYSQL with c#使用 C# 连接到 MYSQL
【发布时间】:2017-10-21 02:27:05
【问题描述】:

这是我的 C# 连接类,但它不起作用:

class DB
{
    MySqlConnection connection;
    //Baglanti adında bir bağlantı oluşturdum

    public bool baglanti_kontrol()
    {
        connection = new MySqlConnection("Server=93.89.xx.xx:3306;Database=database_database;Uid=database_userid;Pwd='password';");
        connection.Open();
        return true;
    }
}

我尝试了同一主题中的每个解决方案。

我的服务器允许我的 IP 地址。

我收到以下异常:

使用方法“mysql_native_password”的用户“xx_xx”的“x.x.x.x”失败并显示消息:用户“xx_xx”@“x.x.x.x”的访问被拒绝(使用密码:YES)”

【问题讨论】:

  • 这是通过 Internet 访问的服务器吗?请注意,通过相对高延迟 (5ms+) 的连接直接连接到数据库服务器是一个坏主意,因为数据库协议通常非常健谈,这会放大延迟的影响。
  • "...但是它不起作用..."
  • MySql.Data.MySqlClient.MySqlException: '无法连接到任何指定的 MySQL 主机。' @GeoffJames
  • @BatuhanAtalay - 那么,您为什么不在原始问题中包含此异常? :)
  • @GeoffJames 我很抱歉。可以帮助解决这个问题吗?

标签: c# mysql database hosting


【解决方案1】:

我解决问题 像这样

"Server=93.89.xx.xx;Port=3306;Database=database_database;Uid=database_userid;Pwd=password;"

问题是我没有定义“端口”和我的密码,如 'password'

【讨论】:

    猜你喜欢
    • 2013-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-14
    • 2012-04-27
    • 2011-12-13
    • 1970-01-01
    相关资源
    最近更新 更多