I am trying to connect to MySQL from my MySQL GUI (Sequel Pro if it matters) using SSH tunnel. However, I keep getting the following error (mysql.log):
[Note] Aborted connection 98 to db: 'example' user: 'example_user' host: 'localhost' (Got an error reading communication packets)
My connection settings look like the following:
- SSH host: example.com
- SSH port: 22
- SSH user: example_user
- SSH pass: ********
- DB host: 127.0.0.1
- DB user: example_user
- DB password: *******
- DB name: example
- DB port: 3306
I can connect to SSH with no problems. I can also connect to MySQL from inside SSH (using mysql -u example_user -p -h 127.0.0.1
)
However, tunneling is not working. I have AllowTcpForwarding yes
in sshd_config. MySQL config has bind-address = 127.0.0.1
.
I am using 16.04 LTS and MySQL Community Edition in my server.
What am I doing wrong? This is the first time I am seeing this issue.
Best Answer
You can create several tunnels via command on workstation by example:
There are:
127.0.0.1
- ip-address tunnel's destination to connect from server,80
and3306
destination ports,10080
and10006
- local workstation's ports. This will allow you to connect to MySql server and to Http server via server's localhost interface. Run commandmysql -p -u db_user -P 10006 -h 127.0.0.1 database_name
on workstation to connect to MySql server. You can connect to PhpMyAdmin web interface, which is allowed only from 127.0.0.1. To do it simply write addresshttp://127.0.0.1:10080
in your browser.