I'm trying to connect to a remote MySQL
database running on server1.com
on localhost
.
I've executed this on my client server:
ssh user@server1.com -L 3306:localhost:3306
And are trying to connect on my client server with:
mysql -h localhost -u mysql-user -p
But are getting:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Googling a bit tells me localhost
forces the mysql
client to setup a socket
which I don't want to do.
Trying to use:
mysql -h 127.0.0.1 -u mysql-user -p
fails, because the remote server server1.com
doesn't accepts connection to the mysql
database via 127.0.0.1
, only localhost
.
What to do?
I've tried socket
forwarding like:
ssh -L /tmp/mysql.sock:/var/lib/mysql/mysql.sock user@server1.com
but fails (on the remote server) with:
channel 2: open failed: administratively prohibited: open failed
I have checked that the local and remote server doesn't have AllowTCPForwarding
and PermitOpen
is not set.