无法连接到GoDaddy的mysql数据库 [英] Unable to connect to GoDaddy mysql database

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

问题描述

我试图连接到我的,我设置了GoDaddy的数据库,
出于某种原因,我使用的是不工作的连接字符串,

它去追赶,当涉及到con.Open()。

这里是连接字符串和测试我使用。
加载的DLL的mysql

在usings:

 使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用的System.Web;
使用MySql.Data.MySqlClient;
使用System.Data这;

在code:

 私人的MySqlConnection CON;
    公共数据库连接()
    {
        CON =新的MySqlConnection();
        con.ConnectionString =SERVER = xxx.db.xxx.hostedresource.com; DATABASE = XXX; UID = XXX; PWD = XXX;;
    }
    公共BOOL Tryconnect()
    {
        尝试
        {
            con.Open();
            返回true;
        }
        抓住
        {
            返回false;
        }
        最后
        {
            如果(con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }


解决方案

由于根据远程连接到虚拟主机数据库的:


  

如果你想连接到一个数据库远程,则必须设置它的时候了&MDASH能够直接访问数据库,你不能在以后启用它。欲了解更多信息,请参见为什么远程连接到主机数据库并的创建MySQL和SQL Server数据库您的托管帐户


  
  

注意:免费托管帐户不能启用直接访问数据库。要升级您的托管帐户,请参阅升级您的托管帐户


I'm trying to connect to my godaddy database that I set up, and for some reason the connection string I'm using doesn't work,

it goes to catch when it comes to the con.Open().

here is the connection string and test that I'm using. loaded the mysql dll.

the usings:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;
using System.Data;

the code:

private MySqlConnection con;
    public DBconnect()
    {
        con = new MySqlConnection();
        con.ConnectionString = "SERVER=xxx.db.xxx.hostedresource.com; DATABASE=xxx; uid=xxx; pwd=xxx;";
    }
    public bool Tryconnect()
    {
        try
        {
            con.Open();
            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

解决方案

As documented under Connecting Remotely to Shared Hosting Databases:

If you want to connect to a database remotely, you must enable Direct Database Access when setting it up—you cannot enable it later. For more information, see Why connect remotely to hosting databases? and Creating MySQL or SQL Server Databases for Your Hosting Account.

NOTE: Free hosting accounts cannot enable Direct Database Access. To upgrade your hosting account, see Upgrading Your Hosting Account.

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

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