HeidiSQL connecting to mysql server - Lost connection...server at reading initial

user1639926 picture user1639926 · Sep 14, 2012 · Viewed 9.2k times · Source

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?

Answer

Matt Weiss picture Matt Weiss · Jun 8, 2018

You must set

AllowTcpForwarding yes
PermitTunnel yes

in /etc/ssh/sshd_config