ben tedder : code things

Using MySQL Workbench with Vagrant

Tired of ssh'ing into your vagrant box, typing mysql -u root -p, the password, finding then using your database, and then performing your sql query? Me too!

It's actually quite simple to setup MySQL workbench to connect to your MySQL instance inside your vagrant box.

Step-by-step guide

  • Download (if you don't have it) MySQL Workbench
  • Within your project directory type vagrant ssh-config in the command line. This will give you a few things you'll need.

    • User: (most likely vagrant)
    • IdentityFile (the path to the private key that MySQL workbench will need)
  • Open up MySQL Workbench and create a new connection

    • Connection Method: Standard TCIP/IP over SSH
    • SSH Hostname:
    • SSH Username: vagrant (from your ssh-config above)
    • SSH Password: leave this alone
    • SSH Key File: Use the IdentityFile path from above. I tried copy/pasting it, but found that I had to actually browse to the file for it to work correctly. Probably user error.
    • MySQL Hostname:
    • MySQL Port: 3306
    • Username: whatever username you usually use
    • Password: the password for the db

After that, make sure your vagrant box is up and running, then you should be able to simply connect to the DB!