Can't create tunnel to access Mysql remotely
I am trying to remotely tunnel to mysql, using the instructions on this page (from my Ubuntu 12.04 vm, fully patched,
with mysql installed):
This is my connection string to set up the tunnel (I am using passwordless login, linode is in my ssh config file)
ssh -L 127.0.0.1:3307:127.0.0.1:3306 linode -N
Once this is done, I attempt to connect to mysql (from another shell):
mysql -u root -h 127.0.0.1 -p -P 3307
I get a password prompt.
When I enter the password, I get the following error in the shell where I issued the mysql command:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
In the shell where the ssh tunnel command is running, I get the following error simultaneously:
channel 1: open failed: connect failed: Connection refused.
Mysql still has the bind address set to 127.0.0.1
I have no problem connecting to Mysql from a normal ssh login with the same credentials.
I retried the ssh forward with the following command:
ssh -vvv -L 127.0.0.1:3307:127.0.0.1:3306 linode -N
Here is the portion of the debug output after the authentication section.
Authenticated to li563-200.members.linode.com ([198.74.62.200]:22).
debug1: Local connections to 127.0.0.1:3307 forwarded to remote address 127.0.0.1:3306
debug3: channelsetupfwd_listener: type 2 wildcard 0 addr 127.0.0.1
debug1: Local forwarding listening on 127.0.0.1 port 3307.
debug2: fd 4 setting O_NONBLOCK
debug3: fd 4 is O_NONBLOCK
debug1: channel 0: new [port listener]
debug1: Entering interactive session.
So I am stuck. Have also tried a number of other recommendations from stackoverflow, etc., but always get the same Mysql error.
Any suggestions welcome.
Ian
Update, as a test I installed Mysql Workbench (client only) on Windows 7-64 and created a connection to the
server using ssh over tcp/ip, with key-based authentication. Error is similar to above:
Failed to Connect to MySQL at 127.0.0.1:3306 through SSH tunnel
at li563-200.members.linode.com with user root.
Lost connection to MySQL server at 'reading initial communication packet',
system error: 0
–
Second update.
Following suggestion from support, enabled skip-networking in my.cnf
This got rid of the "lost connnection" error,
however still getting
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
which seems like progress. As far as I can tell I have granted the needed privileges for root@localhost, and root@127.0.0.1
but will continue to check.
1 Reply
out that I had an entry for 'root'@'%' with no password as the result of earlier
experimentation. I dropped that entry, and was then able to log in over the tunnel
with root@127.0.0.1