1

I am trying to use an SSH tunnel to provide access from my server to the MySQL database on my home server, without using port forwarding on my home router. In other words, I want to run the MySQL server, and establish the SSH tunnel from my home server, and then be able to use the mysql client from the external server. But I keep getting:
bind: Address already in use

I run the mysql server:
service mysql start

and then describe the ssh tunnel:
ssh root@hf2.tr8.us -L 3306:127.0.0.1:3306 -N
or:
ssh root@hf2.tr8.us -L 3306:hf2.tr8.us:3306 -N

Both produce the address in use error. If I create the tunnel first, MySQL refuses to start.

How do I specify the SSH tunnel from the same server that I started MySQL?

Gene Knight
  • 331
  • 3
  • 9
  • Possible duplicate of [MySQL connection over SSH tunnel - how to specify other MySQL server?](https://stackoverflow.com/questions/18373366/mysql-connection-over-ssh-tunnel-how-to-specify-other-mysql-server) – paulsm4 Oct 13 '18 at 16:10

1 Answers1

0

What I was looking for was a "reverse" tunnel: -R. This works, from the server:

ssh root@hf2.tr8.us -R 3306:127.0.0.1:3306 -N

Gene Knight
  • 331
  • 3
  • 9
  • Fair enough - that wasn't clear from the question (at least not to me ;)). Please "accept" your answer. – paulsm4 Oct 13 '18 at 21:00