If you use shared hosting then look for 'SSH access' or something similar in hosting's Control panel. You can make SSH tunnel to your web hosting this way, I used this several times.
I just tried with my website's hosting and it works.
I did the following:
- create SSH keys (in my cPanel: Security, SSH Access, Manage SSH Keys, Generate a New Key). Create strong password for your key. I converted key to PPK format so I can use it with Putty. Download private key. I also had option to upload my own key.
- set up tunnel on your computer. I use Windows, so I created new session in Putty (
https://www.putty.org/):
- in Connection/SSH/Tunnels add new forwarded port (source 3307 because I have MariaDB installed locally, destination 'localhost:3306').
- under SSH/Authentication you browse for private key you downloaded.
- in SSH check 'Enable compression' and 'Don't start a shell or command at all'.
- in Connection/Data enter your username in 'Auto-login username'
- in Session enter host name and name for your session in 'Saved sessions'
- click Save
Now you can open tunnel in Putty (you need to provide password for private key).
After tunnel is open, you access mySQL on your web server by connecting to local host, to port you set as 'source' in Putty, and with database name, user and password as you set in your web control panel.
Of course, I think that for developing and testing, it would be easier if you install mySQL server on your computer. After you are done testing, just change connection parameters.
HTH