无法连接到web托管的mysql数据库

plupiseo  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(309)

我正在使用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处理。我得到一个例外: Unable to connect to any of the specified MySQL hosts. 我知道我的服务器地址、用户名、数据库名和密码都是正确的。我到底在连接什么?它是通过ssh还是其他什么?

m1m5dgzv

m1m5dgzv1#

显然,共享主机不允许您直接连接到mysql数据库。我必须使用renci.sshclient(googleit)设置一个sshclient,并通过它将我的数据库向前移植。多痛苦啊
希望这能帮助有同样问题的人。

相关问题