简体   繁体   English

连接到不允许远程连接的主机上的mysql数据库

[英]connect to mysql database on host that doesn't allow remote connections

I have access to a machine that has mysql on it. 我可以访问一台有mysql的机器。 I'm wanting to use Intellij IDEA (on my personal computer) to talk to the database on the other machine. 我想使用Intellij IDEA(在我的个人计算机上)与另一台机器上的数据库通信。 The other machine's my.cnf file looks like: 另一台机器的my.cnf文件如下:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Bind only to localhost
bind-address = 127.0.0.1
# Increased by request
max_allowed_packet=64M
max_connections=302
open_files_limit = 5000

The bind-address line I believe is preventing me from connecting to the database. 我认为绑定地址行阻止我连接到数据库。 I can't modify this file. 我无法修改此文件。 Is there any way to connect to this database remotely since I can already access it from the remote system by logging in? 有没有办法远程连接到这个数据库,因为我已经可以通过登录从远程系统访问它了?

If ssh is configured to allow port forwarding ( AllowTcpForwarding yes ) you setup port forwarding to create an SSH tunnel, eg 如果ssh配置为允许端口转发( AllowTcpForwarding yes ),则设置端口转发以创建SSH隧道,例如

shh -L 13306:localhost:3306 mysqlserver

With the SSH tunnel established, you would then connect to MySQL on localhost port 13306. 建立SSH隧道后,您将在localhost端口13306上连接到MySQL。

You can tunnel MySQL over SSH. 您可以通过SSH隧道MySQL。

Just google it. 只是谷歌吧。 Check your ssh client, it probably supports tunneling (again, google). 检查你的ssh客户端,它可能支持隧道(再次,谷歌)。

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

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