简体   繁体   English

可以确保与MySQL的远程连接安全吗?

[英]Can remote connections to MySQL be secured?

I've written a program in C++ which stores data to a local MySQL database every 5 seconds. 我用C ++编写了一个程序,每5秒钟将数据存储到本地MySQL数据库中。 Now I need to store the data on webhosted MySQL database which is remote (the webhosting provides remote access). 现在,我需要将数据存储在远程的Web托管的MySQL数据库上(Web托管提供远程访问)。 I think it will be easy to rewrite the program to connect to remote server, but I have a different problem. 我认为重写程序以连接到远程服务器会很容易,但是我有一个不同的问题。

Can I make the connection secure (encrypted)? 我可以使连接安全(加密)吗? I'm afraid that the password can be sniffed. 恐怕密码会被窃听。 Must the server support anything special to make it possible? 服务器必须支持任何特殊功能以使其成为可能吗?

I thought of allowing remote connections to the database from only one specific IP address (my public static IP), which will prevent anybody else from connecting to the database (unless they hack into my WiFi and sniff my password). 我想到了只允许从一个特定IP地址(我的公共静态IP)到数据库的远程连接,这将阻止其他任何人连接到数据库(除非他们侵入我的WiFi并嗅探我的密码)。 So I wouldn't have to worry if someone sniffed my password? 这样我就不必担心有人嗅探我的密码了吗?

What solution would you recommend to me? 您会向我推荐什么解决方案?

One solution for this kind of problem is to use ssh to tunnel to the remote host. 解决此类问题的一种方法是使用ssh隧道连接到远程主机。 I don't have a specific formula, but a SSH client such as putty can be set up to listen on a local port and connect to a remote port which is local to the other end of the connection. 我没有特定的公式,但是可以将SSH客户端(例如putty)设置为侦听本地端口并连接到连接另一端本地的远程端口。

You would log in to your remote host with ssh, then open your mysql connection to a local port, which would have the effect of opening a local connection on the other end of the ssh conneciton. 您将使用ssh登录到远程主机,然后打开与本地端口的mysql连接,这将产生在ssh连接的另一端打开本地连接的效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM