LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Error ssh tunneling mysql requests (https://www.linuxquestions.org/questions/slackware-14/error-ssh-tunneling-mysql-requests-4175494258/)

BCarey 02-08-2014 10:12 AM

Error ssh tunneling mysql requests
 
Hi,

So I'm trying to use an ssh tunnel to access a remote mysql server. I'm using the following ssh command:

Code:

ssh -vv -L 3307:127.0.0.1:3306 -N me@server
When from the client I try then to issue:
Code:

mysql -u root -p -h 127.0.0.1 -P 3307
I get the following result:
Code:

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
while ssh reports:
Code:

debug1: Connection to port 3307 forwarding to 127.0.0.1 port 3306 requested.
debug2: fd 9 setting TCP_NODELAY
debug2: fd 9 setting O_NONBLOCK
debug1: channel 3: new [direct-tcpip]
channel 3: open failed: connect failed: Connection refused
debug2: channel 3: zombie
debug2: channel 3: garbage collecting
debug1: channel 3: free: direct-tcpip: listening port 3307 for 127.0.0.1 port 3306, connect from 127.0.0.1 port 58118 to 127.0.0.1 port 3307, nchannels 4

I have tried this with localhost instead of 127.0.0.1 with no difference. I also added bind-address = 127.0.0.1 to /etc/my.cnf per some advice I found and do not have skip-networking enabled.

I am able to tunnel a vnc session using the same client and server boxes, so I know ssh is basically working well. I think the problem is with mysql but I'm not sure.

Thanks in advance for any help.

Brian

55020 02-09-2014 06:48 AM

Quote:

Originally Posted by BCarey (Post 5113981)
[code]
channel 3: open failed: connect failed: Connection refused

The instance of mysql on your server apparently isn't listening on port 3306, you can confirm this by logging in to your server and doing 'netstat -antp'.

This might be something to do with the following lines of /etc/rc.d/rc.mysqld:
Code:

# To allow outside connections to the database comment out the next line.
# If you don't need incoming network connections, then leave the line
# uncommented to improve system security.
SKIP="--skip-networking"

If none of the above is applicable to your current setup, it might be a firewall issue or something, but we need to eliminate the above circumstances first.

BCarey 02-09-2014 02:50 PM

Thanks, that fixed it. The daemon was not listening. I had assumed that leaving "skip-networking" commented in my.cnf was enough. Thanks for pointing out that part of the rc.mysqld file.

Brian


All times are GMT -5. The time now is 06:20 AM.