【问题标题】:Connecting to a remote MySQL database连接到远程 MySQL 数据库
【发布时间】:2017-03-08 15:13:41
【问题描述】:

我正在尝试在我的测试 WPF 应用程序和 MySql (phpmyadmin) 数据库之间创建连接。 现在,我尝试了其他有类似问题的主题的所有建议,但都没有奏效。

我有一个拥有所有权限的用户 (http://prntscr.com/ehhrdv) 和一个虚拟表。

我的连接代码如下所示:

string conectionString = "Server = r310.reseller.si; Database = ******; Uid = ******; Pwd = ******";



         myConnection = new MySqlConnection(conectionString);

        try { myConnection.Open(); } catch(MySqlException ex)
        {
            MessageBox.Show(ex.ToString());
        }

我得到的错误:

 MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
   at MySql.Data.MySqlClient.NativeDriver.Open()
   at MySql.Data.MySqlClient.Driver.Open()
   at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
   at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
   at MySql.Data.MySqlClient.MySqlPool.GetConnection()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at WpfApplication2.MainWindow.pressMe_Click(Object sender, RoutedEventArgs e) in C:\Users\Tomi\Documents\Visual Studio 2015\Projects\WpfApplication2\WpfApplication2\MainWindow.xaml.cs:line 51

我不确定我的用户是否没有远程连接或其他权限。

我正在从我工作的经销商网站管理数据库。

【问题讨论】:

    标签: c# mysql database


    【解决方案1】:

    尝试添加:

    Driver={SQL Server Native Client 11.0};

    在连接字符串的开头,即:

    string conectionString = "Driver={SQL Server Native Client 11.0};Server=r310.reseller.si;Database=******;Uid=******;Pwd=***** *";

    【讨论】:

    • 你检查你的防火墙了吗?可能是防火墙问题
    • 我应该具体检查什么?
    • 您的出站端口可能被阻塞。尝试完全停用防火墙并再次运行该程序。如果有效,则可能是防火墙问题。
    • 我会试试的,谢谢。我会报告结果
    • 显然我的用户没有足够的权限。我需要请求域所有者授予我完全权限。希望它会起作用
    猜你喜欢
    • 1970-01-01
    • 2013-08-14
    • 2020-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-10
    • 2018-11-23
    • 2013-02-13
    相关资源
    最近更新 更多