digitalist.global // August 23 2017
Connect MySQL Workbench or Sequel Pro to Vagrant via SSH
Using a tool like Workbench or Sequal Pro helps you when working with the database. So it’s really nice to let that application connect to you vagrant machine where the mysql server is running. To do that you need the application to connect through an ssh tunnel. So here’s is how.
In the project folder where you normally execute vagrant up (where your Vagrantfile is located) do
to list your configuration.
In my case it gave me this output:
HostName 127.0.0.1 User vagrant Port 2222 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /your-local-project-folder/.vagrant/machines/default/virtualbox/private_key IdentitiesOnly yes LogLevel FATAL ForwardAgent yes
So here you can see that Vagrant is using private_key file for authentication. To test this you can try in you terminal to
ssh -i .vagrant/machines/default/virtualbox/private_key vagrant@INTERNAL-BOX-IP
this instead of the normal command vagrant ssh witch works without the key file flag.
No you can configure your mysql application using:
SSH Hostname: INTERNAL-BOX-IP SSH Username: vagrant SSH Password: vagrant SSH Key File: local-project-folder/.vagrant/machines/default/virtualbox/private_key MySQL Hostname: 127.0.0.1 MySQL Server Port: 3306 Username: Database username in my case "root" Password: Database user password in my case "password"
and your done.