简体   繁体   中英

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

I have access to a machine that has mysql on it. I'm wanting to use Intellij IDEA (on my personal computer) to talk to the database on the other machine. The other machine's my.cnf file looks like:

[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

shh -L 13306:localhost:3306 mysqlserver

With the SSH tunnel established, you would then connect to MySQL on localhost port 13306.

You can tunnel MySQL over SSH.

Just google it. Check your ssh client, it probably supports tunneling (again, google).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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