I have a server running a web application that uses a mysql database. The database itself is not located on that server -- it's located on another server. The database server is not accessible from my location.
I'd like to use ssh port mapping so I can run mysql
on my Mac laptop and connect to the database. I'm assuming this means I need to connect to my web application server using ssh and port forwarding.
It's like this:
My Mac -> Web Server -> Database Server
I'd like to run the mysql command on my macbook pro something like this:
mysql -u dbuser -hlocalhost -p
and then type in the mysql password.
Also, I connect to my web server using ssh keys.
Add this option to your SSH command line:
-L 127.0.0.1:3306:IP_OF_SQL_SERVER:3306
You will have to use 127.0.0.1 in mysql's -h
option ("localhost" means using Unix sockets locally), and you might want to disable compression in SSH, while activating it in mysql client with the -C
option.