c# - 我在将我的在线托管 MySQL 数据库与我的 C# 应用程序连接时遇到问题
问题描述
我在 000webhost.com 上有一个免费托管的数据库,我正在尝试将此数据库连接到我的 C# 应用程序。当我在 000webhost 上创建数据库时,它给了我在构建连接字符串时使用的这张表
这是我的连接字符串
Server=99.000webhost.io; Database=db_name_that_in_the_table; port=3306; Uid=username_that_in_the_table; Pwd=the_password_i_used_in_phpmyadmin; SSLMode=Preferred
这是我的 C# 代码
try
{
string myconn = "Server=99.000webhost.io; Database=db_name_that_in_the_table; port=3306; Uid=username_that_in_the_table; Pwd=the_password_i_used_in_phpmyadmin; SSLMode=Preferred";
MySqlConnection conn = new MySqlConnection(myconn);
conn.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
当我尝试建立连接时出现此错误
无法连接到任何指定的 MySQL 主机。
PS:我从 phpMyAdmin 的变量选项卡中获得了主机名或服务器名和端口。
问题是什么以及如何解决?提前致谢。
解决方案
问题是 000webhost.com 不支持 MySQL 远程连接。感谢@Uueerdo,他向我指出了谷歌。
推荐阅读
- jquery - Jquery SerializeArray 和推送对象列表
- python - 网页抓取
- 标签
- python - 如何更改 pip 安装到错误的 python 副本的事实?
- html - 如何在 jquery LightSlidder 中使用居中图像设置固定高度?
- python - 如何从 findHomography 中获取旋转角度?
- mysql - 在启动时创建数据库视图 - JPA
- pdf - Craft Pro 3.1.33 - 在管理员用户配置文件中下载 PDF
- php - 为什么php函数exec()返回状态码2
- here-api - HERE geocode API 拉丁化地址
- javascript - Express 验证器不适用于 post 值?