It happens very often that we do not have direct access to our databases, especially if we are talking about internet hosting.
As a rule due to security reasons hosting provider closes all “non-standard” ports (except HTTP, FTP, SSH and some other). As a result users are forced to use various weird solutions like phpMyAdmin. Poor things…
If you have SSH access to your hosting then you are lucky (just as me).
Here we will talk about how to use SSH tunnels to access our “unaccessible” databases from Windows (I believe most of Unix-guys knows how to use SSH-tunneling).
In fact it is very easy.
First of all you should get some SSH client, for example PuTTY or Bitvise Tunnelier. For this article let’s take PuTTY as one of most popular free SSH client for Windows.
I’ll use real-life configuration which I use to access databases on our hosting. Let’s assume that we want to access MySQL database on db.jkiss.org server.
1. Open PuTTY and specify Host Name of your remote server. By default port number is 22, however your ISP may use another one (again, for security reasons). Anyway, you should know it.
2. Go into Connection -> SSH -> Tunnels section.
Enter value on your choice in Source Port box. For example 7777.
Enter “localhost:3306” in Destination box.
It means that SSH will tunnel port 3306 (default MySQL port) from remote server to port 7777 on local computer.
To simplify configuration you may use the same port number on server and on client (3306) – but it won’t work if you have MySQL server on your local computer (and this is exactly my case).
3. Click “Add” button.
4. Click Open button.
5. Login to your remote server through SSH as usual
That’s it, now you may use DBeaver to connect to your remote database. Just connect to localhost:7777 (or other port number you entered on step 2).
Note that you should keep SSH connection (Putty window) open while you are working with database.
Read more about SSH.