![](/img/trans.png)
[英]Connecting with remote mysql database, getting the error “Unable to connect to any of the specified MySQL hosts”
[英]Unable to connect to any of the specified MySql hosts Remote database
您好,我正在創建Windows應用程序登錄頁面。 它已連接到遠程MySQL數據庫。
因此,經過測試,我意識到自己正在運行VPN。 那時仍然可以訪問數據庫。
現在,當我在沒有VPN的情況下運行它時,出現以下錯誤:
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.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at ConnectToDataBase.Form1.LoginWthPasswordHashFunction() in C:\Users\ee\Dropbox\ConnectToDataBase\ConnectToDataBase\Form1.cs:line 38
誰能在這里指出我的錯誤,我將不勝感激。
這是我的連接字符串:
connectionString="Server=MYSQL5016.myWindowsHosting.com;Database=db_123regis;Uid=a123regis;Pwd=**********"
這是程序嘗試連接到數據庫的代碼:
String connString = System.Configuration.ConfigurationManager.ConnectionStrings["WebAppConnString"].ToString();
conn = new MySql.Data.MySqlClient.MySqlConnection(connString);
conn.Open();
queryStr = "SELECT slowHashSalt FROM userregistration WHERE email=?email ";
cmd = new MySql.Data.MySqlClient.MySqlCommand(queryStr, conn);
cmd.Parameters.AddWithValue("?email", textBoxUsername.Text);
reader = cmd.ExecuteReader();
如果您使用的端口與默認端口不同,請嘗試以下格式
Server = myServerAddress; 端口= 1234; Database = myDataBase; Uid = myUsername; PWD = MYPASSWORD;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.