Connecting to MySQL over SSH

Uncategorized No Comments »

The last couple of days I’ve been thinking about setting up a local copy of my websites on my laptop so that I can develop them before I make them live.

Last night I enabled PHP on the apache server built into Mac OSX on my new laptop and installed MySQL on it. I also set up some bash aliases to rsync commands so that I could synchronise the websites from the server to the laptop and back again.

Now that I had local copies of the sites that are synchronised it was time to turn my attention to synchronising the databases between the server and my local machine. I could of configured the server’s MySQL installation to allow remote connections, however, I did not want to do this for security reasons. I decided that I would connect to the MySQL server over SSH by forwarding a port on my local machine to a remote port on the server.

First I needed to create an SSH tunnel using the following command

ssh -fNg -L 3307:127.0.0.1:3306 server.host.name Read the rest of this entry »

WP Theme & Icons by N.Design Studio | Akismet has gobbled 347,538 spam comments...Mmmm Tasty :-)
Entries RSS Comments RSS Log in