Connecting to Vagrant Box with MySQL Workbench

Antoine picture Antoine · Feb 17, 2017 · Viewed 8.4k times · Source

I'm getting started with Vagrant.

I'm trying to connect to Scotch Box with MySQL Workbench.

First I did succeed to connect to mysql with a PHP script inside the box, but I can't do it with MySQL Workbench.

Here is my Vagrantfile:

Vagrant.configure("2") do |config|

config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.network "forwarded_port", guest: 3306, host: 3306
config.vm.hostname = "scotchbox"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]

I've got the error message: "Could not connect the SSH Tunnel" MySQL Workbench error message

I've edited the file "/etc/mysql/my.cnf" to bind-address = 0.0.0.0

I'm on Windows 10

Thank you very much for helping me, I don't know what's wrong, everything I already read online and tried didn't worked.

Answer

Antoine picture Antoine · Feb 17, 2017

I found where was my issue. I wasn't using the right SSH key file...

To find the the location of your key file:

-> Execute vagrant ssh-config in your Vagrant directory.

So my config for this scotch-box:

SSH Hostname: 192.168.33.10

SSH Username: vagrant

SSH Password: vagrant

SSH Key File: your-path-here

MySQL Hostname: 127.0.0.1

MySQL Server Port: 3306

Username: root

Password: root