If you have the database server on different server than the web server and you want to use SSH (direct database access not allowed), you need to establish a SSH tunnel between the servers. To do this, forward a port from web server to the database server. This is done at OS level:

This will open up SSH connection to remoteserver.com using username myusername. All traffic on localhost (127.0.0.1) to port 3306 (the one after -L) will be forwarded to remote server's MySQL port 3306. This assumes you do not have MySQL Server running on the web server. If you do, choose another port.