How to tunnel a mysql connection to your remote server

June 15, 2009

Today I spent alot of the day sorting our development techniques to bring a best practise into what we do. We needed to both be able to connect to the same remote database but both be able to develop locally. So we decided to setup ssh tunnels to our mysql server.

You can quite simply open a ssh tunnel with your server using the following:

ssh -L

You can then connect to the server with php using the following,

DB_USER - root - DB_HOST - :3307 - DB_NAME - db_name DB_PASS - root pass

About me

Hello! I'm David Heward, how are you going? I'm a Senior Devops/Build Engineer, specialising in AWS & Cloud Automation. Based in London. Strong 10+ year background in Software development. Have a read of my blog. Have a look at some of my working projects. Contact me at @davehewy or on Linkedin.