I am using MySQL workbench for accessing a remote database. This is currently working: MySQL workbench screenshot
Now i've tried to access the same database with visual studio 2017, vb.net. This is what i have so far:
Dim connectionInfo As PasswordConnectionInfo
Dim client As SshClient
Dim portFwld As ForwardedPortLocal
connectionInfo = New PasswordConnectionInfo("ipaddress", 22, "me", "password1") With {
.Timeout = TimeSpan.FromSeconds(30)
}
client = New SshClient(connectionInfo)
client.Connect()
If client.IsConnected Then
MsgBox("SSH")
Else
MsgBox("Wrong")
End If
portFwld = New ForwardedPortLocal("127.0.0.1", 0, "127.0.0.1", 3306)
client.AddForwardedPort(portFwld)
portFwld.Start()
MsgBox("Started")
conn = New MySqlConnection("server = 127.0.0.1; port = 3306; uid = 'me'; password = 'password'; database='xxx'")
MsgBox(conn.ConnectionString)
conn.Open()
Unfortunately, i get the following error on the line conn.Open():
: 'Authentication to host '127.0.0.1' for user 'me' using method 'caching_sha2_password' failed with message: Access denied for user 'me'@'localhost' (using password: YES)'
I suppose it has something to do with 'caching_sha2_password', because in mysql workbench --> Users and Privileges --> me, Authentication type is set to Standard.
Edit
I have changed these lines, and now its working :)
portFwld = New ForwardedPortLocal("127.0.0.1", 3305, "127.0.0.1", 3306)
(...)
conn = New MySqlConnection("server = 127.0.0.1; port = 3305; uid = 'me'; password = 'password'; database='xxx'; ssl mode = none;")
Two small additional questions:
- Does it matter which port number i use? I've chosen for 3305, but can I chose random numbers?
- I had to put 'ssl mode = none', is that a security risk?
Thanks