How to connect to a remote MySQL server?
The recommended way is to use what is variously known as "port forwarding" or "tunneling".
This is the most secure way to access remote applications/servers which are not exposed
to public network. Digitalocean has a detailed explanation
here.
Assume that MySQL is running on a server with IP remote-server-ip. Also assume that
MySQL is configured to listen to the default port 3306. Briefly the steps are as follows:
- Generate SSH public/private key pair on your computer
- Copy your public key to remote server
-
Create a tunnel to the remote server
ssh -L 3306:localhost:3306 user@remote-server-ip
Here a secure "tunnel" is being created from port 3306 on your computer to port 3306 on the remote server. - Then from Prosql connections page connect to the remote MySQL server using Host as "localhost" and Port as 3306 (or whatever you used as the first number in above command)