无法连接到000webhost.com上的数据库 [英] Cann't connect to DB on 000webhost.com
问题描述
大家好,所以我在Windows Forms中做了一个projekt。在这个Projekt我使用的是sql server数据库。当我在本地主机上安装我的数据库时,一切正常,但现在我已经在000webhost.com上传了数据库,当我尝试连接到数据库时,它给了我以下信息:无法连接到任何指定的MySQL主机 。我确信所有数据(Servername,用户,传递..)我输入正确。任何人都可以说我犯了错误吗?这是一个连接代码:
Hello guys, so i have made a projekt in Windows Forms. In this Projekt i am using sql server database. Everything is working fine when I have my db on localhost, but now I have uploaded db on "000webhost.com" and when I try to connect to db it gives me following messge: "Unable to connect to any of the specified MySQL hosts". I am sure that all datas(Servername, user, pass..) I have entered correctly. Can anyone say where I have made a mistake? Here is a connection Code:
MySqlConnectionStringBuilder conn_string = new MySqlConnectionStringBuilder();
conn_string.Server = "mysql8.000webhost.com";
conn_string.UserID = "a1613857_***";
conn_string.Password = "*****";
conn_string.Database = "a1613857_****";
//SqlConnection conn = new SqlConnection(conn_string.ConnectionString);
using (MySqlConnection conn = new MySqlConnection(conn_string.ToString()))
using (MySqlCommand cmd = conn.CreateCommand())
{
try
{
conn.Open();
MessageBox.Show("DB is Open");
}
catch(Exception ex)
{
MessageBox.Show("No Connection to DB");
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}
}
推荐答案
你应该检查的事情:
- 服务器名称是否正确
- 你能ping服务器
- DNS是否为该名称返回正确的IP地址,可选择尝试使用IP地址
- 如果防火墙存在,MySql的端口是否打开,默认端口是3306
- 是否配置了MySql服务器使用TCP / IP
- 连接字符串中的服务器名称是否正确
- 用户名是否正确
- 密码是否正确
另外,为安全起见,请为连接字符串构建器定义端口。
Things you should check:
- Is the server name correct
- Can you ping the server
- Does DNS return proper IP address for the name, optionally try using IP address
- Is the port for MySql opened if firewall is present, the default port is 3306
- Is the MySql server running
- Is the MySql server configured to use TCP/IP
- Is the server name correct in your connection string
- Is the username correct
- Is the password correct
Also to be on the safe side, define the port for the connection string builder.
这篇关于无法连接到000webhost.com上的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!