Home > Mobile >  ssh reverse mysql tunnel with a aliased host
ssh reverse mysql tunnel with a aliased host

Time:04-17

I am trying to ssh into my server and then access the mysql on localhost for quick prototype development when testing on live.

Here is my connection in the server:

mysql -h db_master_www -u game -D db_www -p

I then setup my tunnel (sp is my ssh config name)

~ssh -N -L 3336:db_master_www:3306 sp

And on my local machine

hutber@hutber:~$ mysql -h db_master_www -u game -D db_www -p
ERROR 2005 (HY000): Unknown MySQL server host 'db_master_www' (-2)

So logically I'll need to use my host as the ip and not the alias?

CodePudding user response:

When you use an ssh tunnel to map the local port 3336 to the remote port 3306, you would connect to 3336 locally:

mysql -h 127.0.0.1 -P 3336 -u game -D db_www -p

Make sure to use 127.0.0.1, not "localhost" because to the MySQL client, these are not the same.

  • Related