如何访问vps中的数据库
您好,为了访问我的 vps 上的数据库,我必须事先通过 ssh 连接,我已经使用 MySQL WORKBENCH 对此进行了测试,并且它有效。 但是 Netbeans(工作 ide)在创建数据库连接时不提供 ssh 连接,因此我无法将本地应用程序连接到新服务器。 我该如何解决这个问题? 我如何设置我的 jta 数据源来处理这个问题?
非常感谢 此致 伊格纳西奥
Hi in order to access the db on my vps i have to previosly connect via ssh I have tested this with MySQL WORKBENCH and it works.
But Netbeans (working ide) does no provide ssh connection when creating a db connection so I cannot connect my local application to my new server.
How can I go around this?
How can i set my jta datasource to deal with this?
Thank you very much
Best Regards
Ignacio
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有两种方法可以存档来自 netbeans 的连接:
非常不安全的方法:让 MySql 在连接到 Internet 的网络接口上进行侦听。将 mysql 配置文件中的 bind-address 设置为 0.0.0.0,mysql 将侦听所有接口。 http://dev.mysql.com/doc /refman/5.6/en/server-options.html#option_mysqld_bind-address 然后您可以从互联网上的任何地方访问 MySql。
记住:这是一个严重的安全漏洞!搜索 Google,您会发现很多文章详细解释了原因。
安全方法: SSH 可以进行端口转发。这意味着,本地计算机上的一个端口侦听连接并将所有经过加密的流量传输到远程端口。在 Linux 上,这是通过 ssh -L 3306:localhost:3306 YOUR_SERVERS_IP 完成的。然后,您可以在 localhost:3306 上访问 MySql-Server,就像它在本地计算机上运行一样(只是速度较慢)。在 Windows 上,Putty 可以配置为执行相同的操作。我不记得具体在哪里,但在设置连接的对话框中(在命令提示符之前),您还可以配置端口转发。
编写一个在您的服务器上运行的应用程序,该应用程序负责授权并向用户公开 API(例如 Youtube-api,它有一些公共方法,但也有一些需要身份验证)。这可以通过多种不同的方式来完成,例如 XMLRPC(使用 Web 服务器和一些 Web 应用程序)或自定义协议。这可能是最适合生产使用的一个。
There are two ways to archive connectivity from netbeans:
REALLY UNSAFE Method: Make MySql listen on the network-interface connected to the internet. Set bind-address in your mysql-configuration file to 0.0.0.0 and mysql will listen on all interfaces. http://dev.mysql.com/doc/refman/5.6/en/server-options.html#option_mysqld_bind-address You can then access MySql from everywhere on the internet.
Remember: This is a serious security vulnerability! Search Google and you will find a lot of articles explaining in great detail why.
Safe method: SSH can do port-forwarding. It means, that one port on your local machine listens for connections and tunnels all traffic well encrypted to the remote port. On linux this is done with
ssh -L 3306:localhost:3306 YOUR_SERVERS_IP
. You can then access your MySql-Server on localhost:3306 like it is running on your local computer (just slower). On Windows Putty can be configured to do the same thing. I don't remember exactly where, but in the dialog where you setup your connection (before the command-prompt) you also can configure port-forwarding.Write an application to run on your server, which takes care of Authorization and exposes and API to users (like the Youtube-api for example, which has some public methods but also some requiring authentication). This could be done in numerous different ways like XMLRPC (using a webserver and some web-application) or a custom protocol. This is probably the one most suitable for production use.
在防火墙上打一些洞让 NetBeans 连接?
我建议您只需将数据库复制到您的开发环境中,并且不要接触 VPS,除非您准备好“发布”。
Poke some holes in your firewall to let NetBeans connect?
I would recommend you simply copy the database to your development environment and don't touch the VPS unless you're ready to 'release'.