且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用JPA通过SSH连接到远程MySQL服务器?

更新时间:2023-01-20 09:27:27

我假设您想要隧道到只侦听localhost(或防火墙)的远程mysql

I assume you want to tunnel to a remote mysql which only listens to localhost (or is firewalled)

最简单的方法是


  1. 在运行应用程序服务器的帐户之间建立信任关系,为您的应用程序提供JPA服务

  1. setup a trust relationship between the account running the application server providig the JPA service to your application

使用 ssh -L 3306创建隧道:localhost:3306 mysql.server.org 创建一个隧道,将appservers主机上的端口3306连接到端口3306 on mysql服务器的localhost端口。

create the tunnel using ssh -L 3306:localhost:3306 mysql.server.org to create a tunnel which will connect port 3306 on the appservers host to port 3306 on the mysql server's localhost port.

配置JPA以连接到 localhost:3306