Monday, February 4, 2019

How to access mysql installed on your EC2 instance from your local mysql client (sqlyog ..) [ssh tunnelling]


-  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" -L 3307: -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

- Binds local port to remote host port

[N] - Means forwarding ports

Connect to remote mysql using client:

Here I am connecting with sql yog: