我正在使用 VB.NET 连接到 MySQL 数据库。
我有以下代码:
Public Function getListOfDatabase() As List(Of String)
Dim SQL As String = "select * from covenusers"
Dim output As New List(Of String)()
' Set the connection string in the Solutions Explorer/Properties/Settings object (double-click)
Using cn = New MySqlConnection("Server=server33.web-
hosting.com;Port=3306;Database=dbname;Uid=dbusername;
Pwd=password123;")
Using cmd = New MySqlCommand(SQL, cn)
cn.Open() 'this is where it breaks
' do stuff
End Using
End Using
Return output
End Function
我正在使用Imports MySql.Data.MySqlClient
进行MySQL 处理。我收到异常:无法连接到任何指定的 MySQL 主机。
我知道我的服务器地址、用户名、数据库名称和密码都是正确的。我到底要连接到什么?它通过 SSH 还是其他方式?
最佳答案
显然共享主机不允许您直接连接到 MySQL 数据库。我必须使用 Renci.SSHClient (谷歌它)设置一个 SSHClient 并通过它转发我的数据库。好痛苦啊ssh
希望这对遇到同样问题的人有所帮助。
关于mysql - 无法连接到 Web 托管的 MySQL 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48311355/