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 HostName 127.0.0.1 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.
Thank you for sharing this. I was really struggling to get this working, trying all kind of suggestions. The only issue was incorrect path to SSH key file.
This is just brilliant! Thank you 🙂
This works. Thank you
I do not see 2 keys listed under IdentityFile. I can only see one entry:
prakhar@prakhar-Ubuntu:~/WWTS/dashboard$ vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/prakhar/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL