I am a big fan of . Until recently, I had only used MySQL Shell to connect to a local instance of MySQL running on my development machine. MySQL Shell I recently needed to connect to a MySQL database on a Compute Instance in . I wanted to use MySQL Shell but realized I needed to connect to the database using SSH. Fortunately, there is a way to tell MySQL Shell to connect using SSH. OCI Note: This post assumes you already have SSH access set up for your remote server using a private key. First, open MySQL Shell by running this command from a command prompt: mysqlsh This will start MySQL Shell in JS mode. You should see something similar to the image below. Now that we are in Js mode of MySQL Shell, we use the command to connect to a MySQL server tunneled through an SSH connection. shell.connect() shell.connect({uri : "mysql://{user}:{password}!363@127.0.0.1:3306", ssh : "{ssh user}@{remote server}:22", "ssh-identity-file":"{absolute path to SSH key}" }) Let’s break down the different bits of information we are using. - The MySQL user we want to connect to our server with {user} - The password for the above user. We can omit this, and we will be prompted to enter the password. {password} - The user we want to connect to SSH with. {ssh user} - The server IP or domain address for our remote server. {remote server} - The absolute path to our SSH private key file. {absolute path to SSH key} If you are on Windows, you will need to use a forward slash ( ) as your path delimiter instead of a backslash ( ). For example: Note: / \ C:/Users/Dan/.ssh/my-ssh-key Once we run the , you will see a message that we are connected. shell.connect() You can see that we are using a . This is because we specified port 3306 in our connection string. For this connection, we are not using the , which means we will not be able to interact with a with this connection. If you want to use the X Protocol, which uses port 33060, you may need to open up ports on your server’s firewall. Classic Session X Protocol MySQL Document Store Also, note that we are still in JS mode. To switch to SQL mode, enter the following command: \sql We will then see this prompt: Now that we are in SQL mode, we can run SQL commands against the remote database. Once we are done with our session, we can disconnect from MySQL Shell and close the SSH connection. To do this, we run the following command: \quit We can now see that our connection is closed. As you can see, using MySQL Shell over a secured connection using SSH is not that difficult. Also published . here