Connecting remote mysql database using ssh tunnel
The command used to create remote ssh tunnel(sample):
ssh -L 3306:localhost:3306 greenhorn@192.168.1.254
Command used to connect to server using ssh:
ssh greenhorn@192.168.1.254.com
Command to connect to database using user “greenhorn”:
mysql -u greenhorn -p
Command to use a database in particular. In this case I’m using “greenhornDb”:
use greenhornDb;
To show all the tables in the selected database I used command:
show tables;
WARNING:
If you have local mysql running on the same port 3360. You need to stop it first.
Reference:
access-your-mysql-server-remotely-over-ssh