Menu

SSH tunneling to access your site’s database

Updated on August 6th, 2024

While it isn’t common, there may be times you need to access your Flywheel site’s database using an external tool instead of the Database manager in your Flywheel dashboard. Thanks to our SSH gateway and a nifty feature called SSH tunneling, you can do just that.

SSH tunneling allows you to set up a secure connection to transmit data via an encrypted SSH connection. In our example here we’ll be setting up MySQL Workbench, a visual database design tool, but the concepts will apply to any number of tools that can connect to a server via SSH tunneling.

Warning

SSH tunneling is a powerful, technical tool. If you don’t feel confident setting up SSH access and using a tool to manage or access your site’s database, we recommend talking to a developer, as you could break your site.

That said, it’s always a good idea to create a fresh backup before altering your database.



Prep

  1. If you haven’t already, set up your SSH key in your Flywheel dashboard and test your SSH connection.
  2. Using SSH, run cat ~/.my.cnf to view your site’s my.cnf file to get the host IP address, database user, and database password. Alternatively, you can download a copy of your site’s wp-config.php file and get the DB_HOST, DB_USER, and DB_PASSWORD values.
  3. Choose and open the third-party tool you’ll be connecting to the database. We’re going to use MySQL Workbench as an example here, but there are various tools available that can be used.

Note

Puttygen users may need to convert their key to OpenSSH.

  • Open Putty Key Generator.
  • Load the private key by going to File – > Private Key.
  • Go to Conversations and Export to OpenSSH – save the file in a safe location.
  • Go to Workbench and under SSH key file point it to the new OpenSSH file instead of the previous private key file.

Connection Settings

In your chosen tool, fill in the connection settings to set up the connection with your Flywheel site’s database. Here’s an example in MySQL Workbench:

connection settings in MySQL workbench

Connection Name: The name of the site or really any meaningful name you want to give the connection
Connection Method: Standard TCP/IP over SSH
SSH Hostname: ssh.getflywheel.com
SSH Username: username+site-slug OR team+org-name+site-slug (see below for examples)
SSH Password: leave this field empty
SSH Key File: upload the private key file created when you generated your SSH keys
MySQL Hostname: host IP address from my.cnf or DB_HOST IP address from wp-config.php
MySQL Server Port: 3306
Username: user from my.cnf or DB_USER from wp-config.php
Password: password from my.cnf or DB_PASSWORD from wp-config.php

How to enter the SSH username

You can connect to a site using your user account or an organization (org) account.

  • To connect with a user account, enter username+site-slug (Example: flytrevan+super-fly).
  • To connect with an org account, enter the word team first, then org-name+site-slug (Example: team+fly-design-studio+super-fly).

Finding your username

Your SSH username begins with your Flywheel username, which can be found in a couple of different ways:

  1. By connecting to ssh.getflywheel.com via SSH and copying it from the prompt
  2. Or, on your Profile page

user profile in Flywheel dashboard with username highlighted

Note

If you’re connecting to a site owned by an Organization, the Organization’s username can be found before the site slug in the URL when viewing the site in the Flywheel dashboard.Flywheel site url with Organization username and site-slug highlighted

Finding your site-slug

The second part of your SSH username is the site-slug, which can be found in a couple of places:

  1. In the menu, once you’ve connected via SSH.
  2. At the end of the URL (after the site owner’s username) when viewing a site in the Flywheel dashboard.
    Flywheel site url with username and site-slug highlighted

Note

If the site you’re connecting to belongs to another user, replace your username with the site owner’s username.

Save and test the connection

Once you’ve got everything filled out, you can test and save your connection settings. Now you can connect to your Flywheel site’s database whenever you want to!


Need help?

If you have any questions our Happiness Engineers are here to help!

Was this article helpful?

Getting Started

New to Flywheel? Start here, we've got all the information you'll need to get started and launch your first site!

View all

Account Management

Learn all about managing your Flywheel user account, Teams and integrations.

View all

Billing

Everything about billing, invoices and payments can be found here.

View all

Features

Flywheel hosting plans include a ton of great features. Learn about how to get a free SSL certificate, set up a staging site, and more!

View all

Platform Info

All the server and setting info you'll need to help you get the most out of your Flywheel hosting plan!

View all

Site Management

Tips and tricks for managing your sites on Flywheel, including going live, troubleshooting issues and migrating or cloning sites.

View all

Developer Hub

Learn how to connect, deploy, and more with SSH on Flywheel's platform.

View all

Growth Suite

Learn more about Growth Suite, our all-in-one solution for freelancers and agencies to grow more quickly and predictably.

View all

Managed Plugin Updates

Learn more about Managed Plugin Updates, and how you can keep your sites up to date, and extra safe.

View all

 

Flywheel help

Help is just a click away! Log into Flywheel dashboard to instantly chat with an expert, respond to a ticket, or follow along with in-depth documentation. We happily offer support 24 hours a day, 7 days a week, 365 days a year!

Log in

Try Flywheel today

Launch your next site on WordPress in minutes.

 Free migrations  24/7/365 support  14 day demo sites