I've just solved exactly this problem myself. Simply change your ForwardedPortLocal to:
var local = new ForwardedPortLocal("127.0.0.1", 3306, "127.0.0.1", 3306);
In your original, you were giving the source port as 22
. However, your MySql connection would have been connecting to port 3306
on your local machine (which you would then tunnel across to port 3306 on the destination), so you need to ensure that the forwarded port is listening locally on 3306 to start with.
In addition, I've changed localhost
to 127.0.0.1
. A secondary issue I tripped over was that localhost
on my machine was actually resolving to ::1
, an IPv6 address, and the destination server didn't 'speak' IPv6. By switching this to the 127.0.0.1
(IPv4's version of localhost), it ensures that IPv4 is used by default.