0

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?

1 Answer 1

0

Since ssh is providing tunnel from 127.0.0.1:3336 (on the client) to db_master_www:3306 on the remote system, you need to tell the mysql command to connect to 127.0.0.1:3336 so the connection'll be forwarded over the tunnel. I'm not particularly familiar with mysql, but I think to do this you have to specify mysql -h 127.0.0.1 -P 3336 (plus other applicable options).

Note: specifying the host as localhost rather than 127.0.0.1 might work, if the client is a not a Unix/Linux/etc system. If it's a Unix or Unix-like system, -h localhost will make it try to connect via a socket file instead of TCP, and ssh won't forward that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .