The command tells ssh to log in to remotehost.com asmyuser, go into the background (-f) andnot execute any remote command (-N), andset up port-forwarding (-L localport:localhost:remoteport ). In this case, we forward port 3307 on localhost to port 3306 on remotehost.com.
二、连接Mysql
现在,你就可以通过本地连接远程的数据库了,就像访问本地的数据库一样。
1
2
mysql -h 127.0.0.1 -P 3307 -u dbuser -p db
The command tells the local MySQL client to connect to localhost port 3307 (which is forwarded via ssh to remotehost.com:3306). The exchange of data between client andserver is now sent over the encrypted ssh connection.