Revision [1083]

Last edited on 2011-01-26 10:37:38 by FsseInfo
Additions:
see also
SshLocalPortForward
SshRemotePortForward
example howto make a remote mysql server appear on localhost port 3306
by binding local 3306 port to remote 'localhost' mysql 3306 port
$ ssh -L3306:localhost:3306 myremoteusername@remote.server
Deletions:
howto make a remote mysql server appear on localhost port 3306
by binding remote 'localhost' 3306 port to the local 3306 port
$ ssh myremoteusername@remote.server -L3306:localhost:3306


Revision [966]

Edited on 2010-07-12 19:57:47 by FsseInfo
Additions:
==create mysql tunnel==
by binding remote 'localhost' 3306 port to the local 3306 port
$ ssh myremoteusername@remote.server -L3306:localhost:3306
==run mysql command or gui==
then you can use mysql locally to connect to the remote mysql server over ssh
$ mysql -h 127.0.0.1 -u myuser -p
NOTE : DO NOT use the hostname 'localhost' in your mysql command line or you will get
Could not connect to host 'localhost'.
MySQL Error Nr. 2002
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
since mysql tools treat the hostname 'localhost' as a 'magic' word to force mysql to connect via a local socket instead of a tcp port but the local socket will not exist if your mysql server is not local which it is not if it is remote !
so you must either use 127.0.0.1 or add an alias to /etc/hosts
$ cat /etc/hosts
Deletions:
$ ssh myname@remote.server -L3306:localhost:3306
NOTE
DO NOT use 'localhost' in your mysql command line / mysql qui but add an alias to /etc/hosts since use of 'localhost' forces use of a socket which does not exist locally !
$ mysql -h mysshsql -p


Revision [965]

Edited on 2010-07-12 17:07:18 by FsseInfo
Additions:
NOTE
DO NOT use 'localhost' in your mysql command line / mysql qui but add an alias to /etc/hosts since use of 'localhost' forces use of a socket which does not exist locally !
127.0.0.1 mysshsql
$ mysql -h mysshsql -p


Revision [964]

Edited on 2010-07-12 16:50:11 by FsseInfo
Additions:
$ ssh myname@remote.server -L3306:localhost:3306
Deletions:
$ ssh -L3306:remote.server:3306 remote.server


Revision [963]

Edited on 2010-07-12 16:28:41 by FsseInfo
Additions:
>>http://magazine.redhat.com/2007/11/06/ssh-port-forwarding/
>>===SshPortForward===
Deletions:
===SshPortForward===


Revision [962]

The oldest known version of this page was created on 2010-07-12 16:27:54 by FsseInfo
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki