LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-24-2015, 04:59 PM   #1
jdmmis
Member
 
Registered: Jul 2008
Posts: 32

Rep: Reputation: 0
mysql ssh tunnel trouble


I have done ssh tunnel to a remote machine running mysql fine before, but this time I'm having trouble getting it to work for some reason.

This time I'm running CentOS 7 and mariadb. I usually use ubuntu and mysql. The ssh port has changed to port 4445, but I can ssh into the remote machine fine and then issue the mysql -u root -p command and connect, but if I tried to ssh using work bench or navicat it says it can't connect.

Any ideas?
 
Old 06-24-2015, 09:36 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
While I have no idea what work bench or navicat is, and what the particular issues are with the combination of mysql and ssh, some general comments.

Whenever a client can't connect, you need to know:
  • Which port it wants to connect to
  • Is the port open on the server
  • Is something listening on the port
The two last points are easily checked on the server with tools like iptables and ss or netstat. To figure out the port, check your application's configuration (do the server and the client use the same port?) or trace packets with tools like tcpdump or wireshark.

If you are certain that somebody listens on the port and the port is open, tracing will also help you understand why the connection can't be established.
 
Old 06-25-2015, 10:08 AM   #3
jdmmis
Member
 
Registered: Jul 2008
Posts: 32

Original Poster
Rep: Reputation: 0
I made sure the ports were open on the firewall and I netstat and got this

sudo netstat -plutn | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1997/mysqld

this is what I have for my.cnf file
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
character-set-server=utf8

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
 
Old 06-26-2015, 12:12 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by jdmmis View Post
I made sure the ports were open on the firewall and I netstat and got this

sudo netstat -plutn | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1997/mysqld
The my.conf file doesn't seem to contain anything connection-specific (as far as somebody with very little exposure to mysql can see).

You should then be able to connect to this server from a remote client, using the mysql command and a proper connection string.
I don't know why you need to ssh-tunnel to it, but what's the command and what's the error message or behaviour?
 
Old 06-29-2015, 10:03 AM   #5
jdmmis
Member
 
Registered: Jul 2008
Posts: 32

Original Poster
Rep: Reputation: 0
I was able to get ssh tunneling to work. I'm using ssh tunneling since this server will be facing the outside network. At first I had to use grant... @, but realized I didn't need the ssh tunnel so I revoked that and tried another grant permissions and used @ip address and that work. So from what I can tell it is bound to the ip address and just needed a grant permissions for it.
 
  


Reply

Tags
centos, mysql, ssh



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
disable SSH Tunnel on MySQL jrahma Linux - Newbie 2 06-22-2014 05:59 AM
MySQL Cannot start SSH tunnel manager?? michaelinux Linux - Software 4 09-20-2012 07:47 AM
Trouble setting up SSH tunnel tom-ubuntu Linux - Networking 3 02-24-2007 08:14 PM
Strange problem - mysql not working through ssh tunnel ganz_friedrich Linux - Software 0 03-31-2006 08:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration