Benefit of SSH Tunneling
Many hosting companies that provide MySQL hosting block access to the MySQL server from outside the hosting company's network and grant access only to users connecting from
localhost or from a machine
within the network. The major benefit of SSH tunneling is that it allows you to connect to a MySQL server from behind a firewall when the MySQL server port is blocked (see
Figure 3). As long as the hosting company provides SSH access, you can still connect through SQLyog's SSH Tunneling option.
Setting Up SQLyog for SSH Tunneling
Select the Tunnel tab in the connection window (see Figure 4) and provide the information listed in Table 1.
| Username: |
Username to access the SSH server |
| Password: |
Password to access the SSH server |
| SSH Host: |
Address of the machine on which SSH server is running |
| SSH Port: |
Port on which SSH server is listening (22 by default) |
| Localhost: |
Value always is localhost and read-only, because SQLyog creates the SSH port forwarding option on the local machine only |
| Local Port: |
Port on which SQLyog will listen locally for correctly port forwarding MySQL requests. (Note: If you are connecting to two (or more) MySQL servers, then you need to provide two different local port values in the respective connections.) |
| Table 1. SSH Connection Settings Information |
To understand the setup better, connect to a MySQL server using the following real life example:
- Your Web site is hosted on the Web server 234.56.65.78, which also hosts a SSH server that runs and listens on port 22.
- Your MySQL server is located on server 234.56.65.79, and it allows connections only from localhost or another machine within the same network (i.e., 234.56.65.78).
- You publish your Web site on 234.56.65.78 using the username and password your ISP provides (for this example, the username and password are ssh_user and ssh_pwd, respectively).
To complete the setup for this example, you have to input the following values for various server and tunnel options:
| Server Tab |
|
| MySQL Host Address |
234.56.65.79 |
| Username |
Your mysql user name |
| Password |
Your mysql password |
| Database |
The database that you want to connect to (You can leave this field blank.) |
| Port |
The port MySQL is listening (3306 by default) |
| Tunnel Tab |
|
| Username |
ssh_user |
| Password |
ssh_pwd |
| SSH Host |
234.56.65.78 |
| SSH Port |
22 |
| Local Host |
Always localhost |
| Local Port |
Any port that is unused on your local machine (If you don't have a MySQL running on your machine, you can provide 3306.) |
Press Connect to log into your server, and you can then use SQLyog and SSH tunneling to securely and efficiently manage your MySQL database.
Secure Connectivity with SQLyog
SQLyog gives you a choice of connectivity options. No matter what your firewall/proxy/ISP settings are, you should be able to use it to smartly manage your MySQL server(s).