Documentation Home
Connectors and APIs Manual
Download this Manual SSH Connection Examples for X Protocol

The examples in this section demonstrates how to make X Protocol connections using standard TCP/IP over SSH:

Basic SSH Connection with Defaults

This example configures the SSH connection with a default value for the SSH port (22). However, because the connection uses X Protocol to establish the SSH tunnel, the default MySQL port (33060) is provided in the URI-like connection string.

using (var session = MySQLX.GetSession("mysqlx://myUser:test@localhost:33060?sshHostName=;
SSH Connection With SSL Mode

This example creates the SSH tunnel for an anonymous object and it ensures that the use of SSL by denying the connection explicitly if the server does not support SSL.

var sessionOptions = {
    UserID = "myUser",
    Password = "test",
    Server = "",
    Port = 3307,
    SshHostName = "",
    SshUserName = "mySshUser",
    SshKeyFile = @"C:\keys\myOpenSshKeyFile.ppk",
    SshPassPhrase = "sshtest",
    SslMode = MySqlSslMode.Required
using (var session = MySQLX.GetSession(sessionOptions))