You can connect to a remote mysql server via your localhost very simply and securely. You do this by opening a SSH tunnel on the mysql port.

MacBook/Ubuntu/Linux

On a MacBook or Ubuntu/Linux system run this command in your terminal

ssh -L 3306:127.0.0.1:3306 username@myserver.com

Simply replace the username that you have on your mysql server, and replace myserver.com with your servers IP address or domain.

Once this has been done, keep the terminal open and open a new terminal. Check you can connect to the sql database using either localhost or 127.0.0.1 on port 3306.

Leave a Reply

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