更新时间:2023-01-20 07:55:34
嗯.我认为***的方法是在尝试通过 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 中,转到服务并使用以下凭据设置新的 MySQL 数据库连接:
2) In Netbeans go to Services and set up a new MySQL database connection with the following credentials:
主机:127.0.0.1
用户名:root(我假设远程 MySQL 数据库允许远程 root 连接?)
username: root (I'm assuming that the remote MySQL db allows remote root connections?)
password:密码(我猜你一定有你要连接的 MySQL 数据库的密码?!)
password: password (I guess you must have a password for the MySQL database that you're connecting to?!)
jdbc url 应该是这样的:
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!