How to Connect to Your Vagrant’s MySQL Using Sequel Pro

Screen Shot 2016-07-03 at 12.07.51

This was a lot less straightforward than I expected. So I’m posting the incantations here in hopes it’ll save others some time.

Sequel Pro is a very capable Mac-based, open source, MySQL client. One of these many capabilities is to tunnel via SSH to another server. In this case, we’re going from your host machine (an OSX desktop), to your Vagrant guest machine, to access the MySQL database server there. If you don’t currently have a Vagrant machine on hand, try

So, we’re running Sequel Pro in the host machine (OSX).

Step 1

host highlight

The first step is to point the host to your localhost IP:

You’ll also need to specify the database’s user and password. Remember, this is the database on the guest machine.

You can optionally add the database name and port number. In this case, I left them blank.

Step 2

Next we find the vagrant’s IP address.

To get the host, you can access your vagrant machine: in the terminal, go to the machine’s directory, and type vagrant ssh. Then in the vagrant command line, type ifconfig.
 Screen Shot 2016-07-31 at 14.40.34
In my case, the eth1, or ethernet 1, adapter is the one with my IP address: This is an internally accessible address. It cannot be accessed from outside my local area network.
But this command produces a lengthy listing, with a lot of extra information I don’t need, and don’t necessarily understand. There’s an easier command: hostname -I.
Screen Shot 2016-07-31 at 15.09.01
Note that this lists all your IP addresses. Once again, we’re looking for the 192.168.x.x.

Step 3

Next we specify our SSH info.

SSH highlight

So, we use the IP address from Step 2, user is vagrant, and the SSH key, .vagrant.d/insecure_private_key, has been created by your vagrant up process, and lives in your home directory.

Step 4

Now we test, to make sure we have properly set all our parameters.

Screen Shot 2016-07-31 at 15.31.32

And that’s how to do it. If you’re in the mood for some extra pain, check out this very brief explanation of how to set up your SSH tunnel manually:

Leave a Reply

Your email address will not be published. Required fields are marked *