5

New to connecting to databases and have no clue to where to begin to troubleshoot -

I am currently using HeidiSQL to connect to an external Mysql Database Server hosted on the Amazon Web Service - EC2.

I am able to access the database using HeidiSQL with the settings: MySQL (SSH tunnel) Hostname/ip: 127.0.0.1 user: (user) password: (pw) port 3306

in SSH tunnel tab: plink.exe location is set to putty.exe sshhost + port: (my host ip) port 22 private key file: (is set) local port: 3307

Using this configuration I AM able to log into my database. My problem is when I am trying to do it using my own putty commands using the port forwarding:

In Putty: I set SSH>tunnels - source port: 3307, destination (my host ip):3306 Local and Auto. I connect using my passwords and hostip

Back to HeidiSQL, I put my settings to: MYSL (TCP/IP) hostname: localhost user: (user) password(pw) port 3307

and try to connect. I get the following error: SL ERROR (2013): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

From what I have read, this means my ssh tunnel is working but something else is wrong. I am now at a loss on why this doesn't work. Am i not setting something else up properly? Firewalling myself? My ultimate goal is to hook up another application to communicate with the database using ODBC orJDBC using the same port forwarding idea. Are there logs to check somewhere?

user1639926
  • 852
  • 2
  • 11
  • 21
  • on ec2 server: in /etc/ssh/sshd_config added the line: AllowTcpForwarding yes this changed my error message to root@hostip denied. Where this root is the value i put into HeidiSQL as my database user - root. With password and without it denied me access. What other possible settings do I need to enable? – user1639926 Sep 15 '12 at 02:46

3 Answers3

1

You must set

AllowTcpForwarding yes
PermitTunnel yes

in /etc/ssh/sshd_config

Matt Weiss
  • 11
  • 2
0

It seem's like your're trying to do this: http://realprogrammers.com/how_to/set_up_an_ssh_tunnel_with_putty.html It should work. I assume the ssh server and mysql server are running on the remote machine.

In Putty: I set SSH>tunnels - source port: 3307, destination (my host ip):3306 Local and Auto. I connect using my passwords and hostip

It should be: set SSH>tunnels - source port: 3307, destination 127.0.0.1:3306 Local and Auto.

heidisql: MYSL (TCP/IP) hostname: localhost user: (user) password(pw) port 3307

Notice that if you have a MySQL service running on your local machine, on the port your trying to listen (3307 ) you'll get a 2013 error, even if the local service is down! In that case, use any arbitrary unused port.

Also, if the remote mysql server has the user table (mysql database) restricted to certain hosts this won't work. Unless you find out how the server recognize himself (computer name) and add him on the user table or simply you use the '%' wildcard.

JuanLigas
  • 59
  • 1
  • 2
0

Follow below steps it solved my issue while connecting to Live server:

  1. Find your IP (Google - what is my ip).
  2. Go to C-Panel of your Live Server.
  3. Go to Remote MySQL in C-Panel.
  4. Add IP address that you got from Step 1 and save it.
  5. Now try to connect through Heidi SQL.

Please let me know if it helped.

Varun
  • 1