If you prefer to use a client for MySQL such as Workbench, you can connect to the MySQL service in your Vagrant Virtual Machine by using SSH tunnelling. Run “vagrant ssh-config” to get the information you need to configure your client correctly.

vagrant ssh-config

Host default
 User vagrant
 Port 2222
 UserKnownHostsFile /dev/null
 StrictHostKeyChecking no
 PasswordAuthentication no
 IdentityFile /Users/akirkpatrick/Projects/api/puphpet/files/dot/ssh/id_rsa
 IdentityFile /Users/akirkpatrick/.vagrant.d/insecure_private_key
 IdentitiesOnly yes
 LogLevel FATAL

You should see 2 keys listed under IdentityFile, use the path of the first one (not the insecure one) as the location for your SSH Key File in a new Standard TCP/IP over SSH connection in Workbench or an equivalent client. The SSH connection will be over whichever port Vagrant is forwarding (usually 2222, see the Port from the ssh-config output) with the user “vagrant” and the MySQL connection details will be whatever credentials are allowed to connect from within the VM.

Vagrant SSH key for TCP/IP over SSH connection

  • By: Andrew Kirkpatrick
  • In: Uncategorised
  • Under: