In this tutorial I will explain how to use the very convenient MySQL query browser to connect and work to your remote MySQL server, where you do not allow remote TCP connections for security reasons (and you do very well!)
Many users use web gui tools like phpMyAdmin, but they have limitations and are some times frustrating to use.
I suppose you work in Windows. If you work in Linux, this tutorial will help you too and you can ommit the part of the Cygwin installation (see below).
To accomplish the goals of this tutorial we will use 2 great free tools:
- MySQL gui tools
Get them now!
I also suppose that you have ssh access to your database server. If not (eg you are on a shared hosting environment), you can not proceed with this tutorial.
After the downloads get complete, install the tools. The installation is pretty straightforward and is out of the scope of this tutorial. One thing you have to be carefull about though, is to install the package openssh in Cygwin, as this will do the most tricky and clever part of the dirty job for us 🙂
Now run Cygwin simply by double clicking the shortcut that you may have created on your desktop or by using the cygwin.bat at the directory you installed Cygwin. A unix like command line appears. In there you must enter the “magic” command:
ssh -N -f -L 4783:127.0.0.1:3306 username@servername
where username the ssh user account to connect to your server and servername the IP or URL of your server. This supposes that you ssh to your server at the default port. If you connect at another port, you should user the parameter -p port as well.
But what does this command do? It creates an ssh tunel from your pc to your server and each call that arrives at your pc at the port 4783 (this is random you can choose whatever you like and is free on your pc), is forwarded to port 3306 (the MySQL service port) at your server! If you have configured your MySQL server to listen to another port, you should change the command accordingly!
Now, things are easy, open MySQL query browser and create a new connection. As servername use localhost (!) and as port the one that you defined above (4783). Insert the username and password of your remote db server though!
You will get a warning that you have not specified a default schema (if you havent). Just ignore it!
If you have done everything ok, you should be browsing your remote MySQL database as if it where on your localhost!