0

I want to make remote connection via socket pipe (mysql.sock) on remote server, which is mounted to directory using sshfs. But I experience some problems. Here's an example:

I have 2 servers. One of them is mysql server behind NAT (but ssh port is opened). So I can't directly open an mysql connection by:

mysql -h mysql-server -u root -p

I tried mount mysql-server using sshfs:

sshfs user@mysql-server:/ ~/db

Remote mysql.sock file in now located under: ~/db/var/lib/mysql/mysql.sock

but after calling:

mysql --socket=~/db/var/lib/mysql/mysql.sock -u root -p

I got:

Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '~/db/var/lib/mysql/mysql.sock' (111)

bind-address is not present in config file.


So the question is: How to connect to remote socket in directory mounted through ssh?

OR

Is there any possibility to connect to remote mysql using ssh (all others ports are closed)? I need it to use with php later...

1 Answer 1

5

I don't think that is going to work... Sockets are not supported over sshfs according to the sshfs developers.

Why aren't you just forwarding the MySQL TCP port over your SSH tunnel?

ssh -L 3306:localhost:3306 user@mysql-server
mysql localhost ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.