How do I connect to MySQL using SSH on Windows?

To make it easier to get in touch with us, from the 24th of March 2016 all support tickets will need to be submitted from your Crucial Control Panel.

In order to remotely connect to a database in your shared or reseller web hosting account, you will need to take additional steps for the connection to be successful because the MySQL port is closed. 
You will need to establish an SSH tunnel which will allow you to connect to the MySQL server via the SSH connection.

Depending on your MySQL client, this may be available from the configuration options for the software. Once such program for Windows is MySQL Workbench.

If your MySQL client does not provide this functionality you can establish the SSH tunnel manually.

The steps to do this are outlined below, and cover the configuration of Putty on Windows.

  1. Contact support to ensure that SSH access is enabled for your webhosting account (Reseller accounts can do this themselves from WHM under the edit account options).
  2. Open Putty and enter the name of your website into the 'Host Name' option.



  3. Enter a name for the connection in the 'Saved Sessions' option.
  4. Click onto the 'Connection' category on the left, and enter ‘30’ into the 'keepalive' option.



  5. Ensure the 'Enable TCP keepalives' option is ticked.
  6. Click onto the 'Data' sub-section on the left and enter your cPanel username into the 'Auto-login username' option.



  7. Click onto the 'SSH', and then 'Tunnels' sub-categories on the left.
  8. Enter '3306' into the 'Source port' option.



  9. Enter '127.0.0.1:3306'' into the 'Destination' option, and click the 'Add' button.
  10. Click back onto the 'Session' category on the left and click on the 'Save' button to create a new session.
  11. Once this is completed you can open the session by ensuring it is selected and pressing the 'Load' button followed by the 'Open' button.
  12. You will be prompted for your cpanel password, enter it and press Enter.

 

With the session established, you can now use a mysql client to connect to the mysql server.

You will need to ensure the following details are used in your MySQL client:

Host:

localhost

Port:

3306

Username:

your database username

Password:

your database password

If you are using a Mac, please refer to our separate guide which is available here.


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk