Assumptions:
- You have access to EC2 instance with ssh key pair (.pem)- Mysql server is installed on you EC2 instance which is up and running
- You should have one mysql user with all necessary privileges
Create a ssh tunnel on Mac os or linux:
Open command prompt and run below command from your terminal:
ssh -i "My-key.pem" ubuntu@ec2-13-23--123.us-east-2.compute.amazonaws.com -L 3307:127.0.0.1:3306 -N
[My-key] - Point where your key pair is located
[3307] - Changed the port from 3306 to 3307, in case if you have mysql server already running locally on default port
[L] - Binds local port to remote host port
ssh -i "My-key.pem" ubuntu@ec2-13-23--123.us-east-2.compute.amazonaws.com -L 3307:127.0.0.1:3306 -N
[My-key] - Point where your key pair is located
[3307] - Changed the port from 3306 to 3307, in case if you have mysql server already running locally on default port
[L] - Binds local port to remote host port