Home>

I want to connect to Lollipop's MySQL server from local PC via Lollipop's SSH server.

(* Cannot connect to Lollipop MySQL server directly from local PC )

Environment

OS: macOS
Terminal: mac default terminal

Work flow
  1. Tunnel to SSH server at local terminal and connect to SSH
  2. If it succeeds, open another terminal and connect to the remote MySQL server

I did this, but I couldn't connect to the MySQL server after all.

1 succeeded successfully, but when I hit the following command, I got an error all the time and I don't know what to do.

Source code
** Tunneling to SSH server **
ssh -L Local port: DB host: 3306 SSH user @ SSH host -p SSH port
** Connection to remote mysql server **
./mysql -u DB user -h localhost --port = local port -p
  ssh server
  IP: XXX.X.XXX.XXX
  Host: ssh ***. Lolipop.jp
  User: lovepop.jp-*****
  password:*********
  DB server
  IP: XXX.XX.XX.XXX
  Database name: LAA *****-*****
  Host: mysql ***. Phy.lolipop.lan
  User name: LAA *****
Error
"ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0"
Tried for error

I did a lot, but eventually I got the above error and did the following to deal with it, but it didn't work.
・ Action 1
・ Action 2

Please help ... w

  • Answer # 1

    ssh -L Local port: DB host: 3306 SSH user @ SSH host -p SSH port

    That's right, but

    ./ mysql -u DB user -h localhost --port = Local port -p

    This is wrong,

    ./ mysql -u LAA ***** -h mysql ***. phy.lolipop.lan -p

    . (--Port may or may not be present)

  • Answer # 2

    What about Sequel Pro on a Mac?
    You can also set up an SSH connection