简体   繁体   中英

I am trying to connect to my remote MySql Database within Visual Studio

I bought a Classic VPS from OVH with a cPanel 11.36 Installed in it, And I created a Database. Now I'm trying to connect to that database with a simple c# winform app.

MySqlConnection conn;
string myConnectionString;
myConnectionString = "server=vps158***.ovh.net; port=3306; database=My_Database; uid=user; pwd=xxxxxx;";
try
{
    conn = new MySqlConnection();
    conn.ConnectionString = myConnectionString;
    conn.Open();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
    MessageBox.Show(ex.Message);
}

But I get the following error ?

Unable to connect to any of the specified MySQL hosts.

user3343494, I solved this question, accessing the advanced configuration when adding the connection. It seems to be some kind of bug. Fill the fields with the information you have about your remote connection and try to connect. Worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM