I have made ssh tunnel from my laptop to my home pc
Code:
ssh linuxuser@homenet -L 3307:homenet:3306 -N
I can run mysql from my laptop connecting to localhost:3307
Code:
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
Code:
error No.2013 "Lost connection to MySQL server during query";
2) Using java
Code:
connection = DriverManager.getConnection("jdbc:mysql://localhost:3307/mydatabase",
"mysqluser", "mysqlpass");
gives error message
Code:
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.
SQLErrorCode: 0
SQLState: 08S01
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
Code:
| Host | User |
| % | mysqluser|
|localhost | root |