0
guest OS ---> Ubuntu 22.04.1 LTS
host OS ----> MacOS 12.5.1
VMware Fusion: Player Version 12.2.4 (20071091)
mysql: Ver 8.0.30-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
mysql Workbench 8.0.30

I'm trying to configure mysql Workbench to connect to a mysql server hosted in a virtual machine. I own and control both host and guest OSs and the mysql server.

I can connect to the Ubuntu machine via VMware's Connect to SSH option. This uses server 172.yy.yy.yy and port 22. I also provided the u/name and p/wd for the Ubuntu OS. That all work fine and I can sudo into mysql using that. I can also log in using another user that has host 'localhost'.

I cannot for the life of me figure out what I should enter into mysql workbench in order to connect though. I have created a remote access user that has as host the ip address of the MacOS (I got this just by googling 'my ip').

I have also edited /etc/ssh/sshd_config to include: ListenAddress xx.xx.xx.xx (where xx.xx.xx.xx is my host OS's IP address).

Connection Method: I've selected Standard TCP/IP over SSH

SSH Hostname: my_guest_OS's_IP_address

SSH Username: my_guest_OS's_username

SSH Password: my_guest_OS's_username's_pwd

MySQL Hostname: 0.0.0.0

MySQL Server Port: 22

Username: my_remote_mysql_login_name

Password: my_remote_mysql_login_pwd

Default Schema: <leave_blank>

I am currently getting the below error message:

Failed to Connect to MySQL at 0.0.0.0:22 through SSH tunnel at <my_guest_OS's_username>@<my_guest_OS's_IP_address> with user <my_remote_mysql_login_name>

Cannot open SSH Tunnel: Connection refused
2
  • If you’re connecting through an SSH tunnel, then the MySQL host should be 127.0.0.1 and the port should be 3306 🤔
    – matigo
    Aug 24, 2022 at 13:40
  • I get the same error message with that I'm afraid. Aug 24, 2022 at 13:48

1 Answer 1

0

SUCCESS!

So after a little more research I have now connected. There were three problems.

  1. Wrong IP address. The SSH Hostname was NOT discoverable by simply opening a browser and googling 'my ip'. I needed to log into the terminal and use ip route and then find the src line to get the host address for SSH.

  2. I had read that I should create a separate mysql user for remote access and this should have as hostname the IP address from which I would be connecting. This turns out not to be the case. Workbench, it seems, insists on using username@localhost when trying to connect. So user_remote@localhost will always fail if the user username and host listed in the user table is actually, say [email protected]. To get around this I just logged in with my local user. Workbench then sent user_local@hostname and everything worked.

    | user             | host        |
    +------------------+-------------+
    | user_remote      | xx.xx.xx.xx |
    | user_local       | localhost   |
    +------------------+-------------+
  1. @matigo was correct. I needed 127.0.0.1 and 3306 in the mysql hostname and server port.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .