Patrick Bassut
Patrick Bassut

Reputation: 3338

Error when connecting to MySQL over SSH Tunnel on OSX

I'm trying to access amazon ec2 mysql server remotely.

My problem is(for sure) with Mac OSX. Cause when I try to connect through the same mysql client(MySQL Workbench 6.0) on windows inside a VM hosted from this very same MacOSX machine, it works just fine.

I've searched a lot about this problem. And this guy figured the problem was with a third-party app called iStatPro(which is actually a dashboard widget). I had the same widget, and I tried to remove it, and it didn't work.

Is it possible that some other app is blocking my 3306 port(or the 22 ssh default port for that matter)? If so, what is the best way to figure which one?

Thanks in advance.

EDIT:

The error I get when trying to connect, is exactly the same error that guy gets. Which is:

Your connection attempt failed for user 'xxxx' from your host to server at xxxx.yyyyy.zzzzz.edu:3306:
Can't connect to MySQL server on 'xxxx.yyyyy.zzzzz.edu' (61) 

EDIT [2]:

Also, then I try to connect using mysql workbench it refuses the connection immediately. Making me think, it don't even have the chance to connect to ssh tunel, getting refused locally.

EDIT [3]:

The parameters I'm using to connect to the mysql remote server is: SSH Hostname: 99.999.999.999:22 SSH Username: ubuntu SSH password: empty SSH Key File: respective .pem file MySQL Hostname: 127.0.0.1 MySQL Server Port: 3306 Username: root Password: mypassword default_schema: my_default_schema

EDIT [4]:

I can establish the connection through terminal just fine.

Upvotes: 1

Views: 2369

Answers (2)

Mr-IDE
Mr-IDE

Reputation: 7661

To workaround the SSH connection problem in MySQLWorkbench, you must first create an SSH tunnel manually, in the Terminal:

ssh -nNT -L 1234:my-ec2-server.us-west-1.rds.amazonaws.com:3306 [email protected]

Where:

  • Explanation of SSH flags: here.
  • 1234 = Local port on your computer
  • 3306 = Standard MySQL database port on the host, to map to
  • firstname.lastname = your SSH login username
  • xxx.xxx.xxx.xxx = IP address of your SSH gateway machine (Bastion Host)

Then setup MySQLWorkbench to connect to a localhost database on port 1234:

MySQLWorkbench -> Database -> Manage Connections -> New -> Specify a name

  • Connection Method = Standard TCP/IP
  • Hostname = localhost
  • Port = 1234
  • Username = Your MySQL username
  • Default Schema = Your database name

When you have finished working with the database, press Ctrl+C in the Terminal to manually disconnect/close the SSH tunnel.

Upvotes: 1

Astrid
Astrid

Reputation: 1312

Try using Network utility (Applications > Utilities > Network Utility), In the last tab you can run a port scan on localhost.

Every port which is being used will be listen together with the name of the service which is using the port.

Hope this helps.

Upvotes: 0

Related Questions