更新时间:2023-01-20 08:05:21
嗯.我认为***的方法是在尝试通过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!