Reputation: 309
I copy command from form Fortrabbit to access my database using a SSH tunnel:
#Access the database from outside using a SSH tunnel
ssh -N -L 13306:myapp.mysql.eu1.frbit.com:3306 [email protected]
I entered my passphrase. But when I hit enter nothing happens.
Could anyone help?
Upvotes: 1
Views: 199
Reputation: 640
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:
https://help.fortrabbit.com/mysql
Upvotes: 1
Reputation: 4499
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.
Upvotes: 1