Chassis.io uses Vagrant and VirtualBox to setup a Virtual Machine that hosts your WordPress site. This post covers how you can connect to your WordPress database that exists on that Virtual Machine. I’ll be using Windows and HeidiSQL for the purpose of this post. The connection information I use in this post comes from this GitHub issue.
Connecting with HeidiSQL
HeidiSQL is my favorite query browser for MySQL and MariaDB databases. I like the layout and the interface is nice and clean.
When you first open HeidiSQL you will see the interface for creating a new Database connection.
Choose whichever name you want to help you remember what this connection is for. I’ve named mine “Chassis” because it’s my connection to the database Chassis.io setup. You’ll also want to set the following settings:
- Network type:
MySQL (SSH tunnel)
- Hostname / IP:
That’s it for the basic settings. Now for the SSH Tunnel settings.
HeidiSQL – Plink.exe and Private Key
HeidiSQL uses a utility called “plink.exe” for it’s SSH capabilities. plink.exe is made by the same author who wrote PuTTY (which I’m sure you’ve heard of). If you haven’t got plink.exe downloaded you can find the latest exe on this page. You’ll want to grab both
puttygen.exe. I stuck both utilities inside a “PuTTY” folder in my
Program Files (x86) directory. You can stick them wherever you want to.
Ok, before we setup the SSH Tunnel settings we are going to want to setup the Private key file that plink.exe will use to communicate with your Virtual Machine. PuTTY utilities use specific private key files called
.ppk files. We are going to want to convert the Vagrant provided private key file to a
.ppk file for use by plink.exe. Luckily, the
puttygen.exe utility you downloaded makes this conversion simple.
puttygen.exe. This will launch the “PuTTY Key Generator”. Load in the Vagrant provided private key file by using File > Load Private Key. Navigate to the location of your Vagrant private key file. Mine was located in
C:\projects\chassis\.vagrant\machines\default\virtualbox. Your location may be different depending on where your Chassis project is. Find the “private_key” file and open that. The PuTTY Key Generator will take care of loading the key in for you. You should see a “Successfully imported foreign key …” message. Now click “Save private key”, choose a name for it, and save it. I just saved it exactly where the other private_key was.
Woot! Now we can fill out the HeidiSQL SSH tunnel settings. Remember where you saved that
.ppk file because you’ll need it for this next step.
HeidiSQL – SSH Tunnel Settings
Click on the tab for “SSH tunnel” to access the HeidiSQL Session Manager SSH Tunnel settings.
Alright, let’s plug in the values!
- plink.exe location: Insert the path to your
- SSH host + port:
- Password: just leave this blank
- plink.exe timeout: default is fine
- Private key file: Path to the
.ppkfile we created above
- Local port:
Now we come to the moment of truth. Push the “Save” button on the HeidiSQL session manager to save your changes. Now push the “Open” button and HeidiSQL should connect to your Vagrant hosted WordPress database. Woot!