在Netbeans中通过SSH连接到MySql数据库 [英] Connect to MySql db over SSH in Netbeans

查看:98
本文介绍了在Netbeans中通过SSH连接到MySql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Netbeans中,我需要通过SSH创建到远程MySql数据库的连接.我得到了SSH主机名,SSH用户名,SSH密码,MySql主机名(127.0.0.1)和MySql用户名(根).在新的连接向导中,由于涉及ssh,所以我不确定该怎么办.我的JDBC网址应该是什么样子?甚至可以通过GUI向导来实现这一点?

In Netbeans, I need to create a connection to a remote MySql database over SSH. I am given SSH hostname, SSH username, SSH password, MySql hostname (127.0.0.1) and MySql username (root). In a new Connection Wizard I am not sure what to do since there is ssh involved. How should my JDBC Url look like? Is it even possible to achieve this from a gui wizard?

推荐答案

嗯.我认为最好的方法是在尝试通过NetBeans连接到远程数据库之前设置端口转发.

Hmm. I reckon the best way for you to do this is to set up port forwarding before attempting to connect to your remote database via NetBeans.

我不确定您使用的是什么操作系统,但是假设您使用的是Linux,请按照以下步骤操作:

I'm not sure what OS your using but, assuming you are using some flavour of Linux here are the steps to take:

1)将本地端口转发到远程MySQL数据库服务器 打开一个终端窗口,然后输入:

1) Forward a local port to your remote MySQL Database server Open up a terminal window and type:

sudo ssh -L 6666:127.0.0.1:3306 <your_SSH_username<@<remoteserver.com>

系统将提示您输入SSH密码.输入它.

You'll be prompted for your SSH password. Enter it.

2)在Netbeans中,转到Services并使用以下凭据建立新的MySQL数据库连接:

2) In Netbeans go to Services and set up a new MySQL database connection with the following credentials:

主机:127.0.0.1

host: 127.0.0.1

用户名:root(我假设远程MySQL数据库允许远程root连接?)

username: root (I'm assuming that the remote MySQL db allows remote root connections?)

密码:密码(我想您必须为要连接的MySQL数据库输入密码吗?!)

password: password (I guess you must have a password for the MySQL database that you're connecting to?!)

jdbc网址应如下所示:

The jdbc url should look something like this:

jdbc:mysql://127.0.0.1:6666?username=root&password=<your_remote_db_root_password>

此处上有一篇不错的文章,以了解更多信息有关港口转运/隧道运输的详细信息.

There's a good post here for more details on port fowarding/tunnelling.

祝您好运,希望对您有帮助!

Good luck and I hope this helps!

这篇关于在Netbeans中通过SSH连接到MySql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆