HY!
我刚刚创建了一个小的MYSQL远程c#工具。
问题是,我收到错误:无法连接到任何指定的MySQL主机
CODE:
string myConnectionString = "SERVER=http://xxx;PORT=3306;" +
"DATABASE=xxx;" +
"UID=root;" +
"PASSWORD=xxx;";
MySqlConnection connection = new MySqlConnection(myConnectionString);
MySqlCommand command = connection.CreateCommand();
command.CommandText = "SELECT * FROM USER";
MySqlDataReader Reader;
connection.Open();//Here ocurres the error
Reader = command.ExecuteReader();
string tmp ="";
while (Reader.Read())
{
string row = "";
for (int i = 0; i < Reader.FieldCount; i++)
row += Reader.GetValue(i).ToString() + ", ";
tmp += row + "\n";
}
MessageBox.Show(tmp);
connection.Close();
当我从远程使用MYSQL Workbench时,我可以正常登录
请帮忙
答案 0 :(得分:3)
SERVER=http://xxx
在这种情况下,数据库连接不需要http://
的预挂起。