开发者

How to connect to MySQL using ssh tunnel with perl

开发者 https://www.devze.com 2023-01-25 03:59 出处:网络
I am using Amazon EC2 instance of MySQL and need to modify my perl scripts 开发者_JAVA技巧to connect to the database using ssh tunnel (instead of the plain old hostname:port). Any help is appreciated

I am using Amazon EC2 instance of MySQL and need to modify my perl scripts 开发者_JAVA技巧to connect to the database using ssh tunnel (instead of the plain old hostname:port). Any help is appreciated

Thanks


Open a tunnel:

ssh -fNL 3306:localhost:3306 myname@myhost

Then connect to localhost:3306


well after establishing SSH tunnel connection differs only with hostname and it's 127.0.0.1 (localhost) in that moment


MySQL attempts to map localhost[:port] connections to use a local (UNIX) socket; you should use 127.0.0.1 for a tcp/ip socket.


One note in regard to answer by chris - on some setups "localhost" and "127.0.0.1" make a difference. In my case, localhost didn't work, while 127.0.0.1 did work flawlessly.


I don't know about ssh but you can encrypt connections between your application and your DB Instance using SSL, would that be sufficent for you?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号