You have set up a port forwarding from your localhost:3306 to remoteport:3306.
What this means is the mysql database runinng on remote machine is now accessible at your localhost port 3306.
You can connect it using
Shell
mysql -u <username> -p<password> --host=127.0.0.1 --port=3306
JDBC
String url = "jdbc:mysql://localhost/<db_name>";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
Connection conn = DriverManager.getConnection (url, "username", "password");
This will only work as long as the SSh session opened previosly is alive.
That nothing seems to happen is a good sign:
The connection seems established, and you can, in a separate terminal window , use that existing connection for your mysql work.
See also the fortrabbit tutorial on mysql connection:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.