June 6, 2018 · Setup Guides

Connect MySQL Workbench with MySQL/MariaDB in Vagrant over SSH

This post outlines how to connect MySQL Workbench with a MySQL/MariaDB service running inside a Vagrant Virtualbox VM over SSH.

I. Configure Vagrant

To make sure that the port does not change and mess up your MySQL Workbench config, it is a good idea to set a fixed SSH port for your VM. For this example, I used 2222.

Include this line in your Vagrantfile:

config.ssh.guest_port = 2222

II. Configure MySQL Workbench

By default, vagrant creates a privatekey at:


Open up MySQL Workbench and setup a new connection the following parameters:

  • Connection Method: Standard TCP/IP over SSH
  • SSH Hostname:
  • SSH Username: vagrant
  • SSH Key File: .vagrant/machines/<hostname>/virtualbox/private_key

Make sure to fill in "Username" and "Password" with your database's details.

Here's an example:


Click on "Test Connection" to try it out then click on "Ok" to save the connection.