I have made ssh tunnel from my laptop to my home pc
ssh linuxuser@homenet -L 3307:homenet:3306 -N
I can run mysql from my laptop connecting to localhost:3307
mysql -h localhost -P 3307 -u mysqluser -p
and in command prompt it works fine, I can issue commands and view outputs.
But connection over ssh tunnel is refused when I want to use it from other software:
1) MySQL client (SQLyog) connection to localhost:3307 gives
error No.2013 "Lost connection to MySQL server during query";
2) Using java
connection = DriverManager.getConnection("jdbc:mysql://localhost:3307/mydatabase",
gives error message
Communications link failure
The last packet successfully received from the server was 16,139 milliseconds ago. The last packet sent successfully to the server was 16,075 milliseconds ago.
I can still successfully connect from SQLyog and from java directly to homenet:3306; It is not a firewall issue, since I have turned both firewalls off.
I have increased connection timeout in my.cnf
It is permitted to user mysqluser to connect from any host
| Host | User |
| % | mysqluser|
|localhost | root |