You can connect to MySQL on computer #1 and you can connect from computer #2 to computer #1 via SSH, but you cannot connect directly from computer #2 to computer #1 with MySQL – and you want/need to do so.


Create an SSH tunnel to route the MySQL connection. Here’s how.

On computer #2: Run the following command in a terminal:

ssh username@computer1address -L 3307:localhost:3306 -N

You’ll have to use your password/keys to log in at this point. What some of the options mean:
1) “-L 3307:localhost:3306″ means that we want to bind port 3307 on the local machine (computer #2) to port 3306 on the remote machine (computer #1). After the connection is made, connections on computer #2 going to localhost:3307 will actually be connecting to computer #1′s port 3306.
2) “-N” means to not expect anything to happen after the connection is made. It will just sit there and allow traffic in the background.

Now, you should be able to connect from computer #2 to MySQL on computer #1. On computer #2, now try:

mysql -h -P 3307 -u username -ppassword
Posted in Linux
Share this post, let the world know

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">