unable to connect to mysql via ssh tunnel

  • Follow


I've created an SSH tunnel to a MySQL server on port 3333 (of the
local machine), however, I'm still unable to connect to the MySQL
server.  Here's the command I'm trying:

mysql -u root -ppassword --port 3333

Here's the error I'm getting:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/tmp/mysql.sock' (2)

The command I'm using to create the tunnel:

autossh -2 -fN -M 0 -R 2200:localhost:22 root@servername.com -i
cert.pem -L 3333:127.0.0.1:3306 -o UserKnownHostsFile=/dev/null -o
StrictHostKeyChecking=no

Any ideas?
0
Reply yawnmoth 7/12/2010 6:39:19 PM

yawnmoth wrote:
> I've created an SSH tunnel to a MySQL server on port 3333 (of the
> local machine), however, I'm still unable to connect to the MySQL
> server.  Here's the command I'm trying:
> 
> mysql -u root -ppassword --port 3333
> 
> Here's the error I'm getting:
> 
> ERROR 2002 (HY000): Can't connect to local MySQL server through socket
> '/tmp/mysql.sock' (2)
> 
> The command I'm using to create the tunnel:
> 
> autossh -2 -fN -M 0 -R 2200:localhost:22 root@servername.com -i
> cert.pem -L 3333:127.0.0.1:3306 -o UserKnownHostsFile=/dev/null -o
> StrictHostKeyChecking=no
> 
> Any ideas?

By default the mysql client tries to use the socket, you need to tell it to
use the tcp connection instead by adding

-h 127.0.0.1

-- 

  //Aho
0
Reply J 7/12/2010 6:55:23 PM


1 Replies
737 Views

(page loaded in 0.006 seconds)

Similiar Articles:













7/24/2012 1:33:24 AM


Reply: