All Collections Databases MySQL

MySQL

Learn how to use MySQL databases with Hatchbox

Updated

Hatchbox supports two types of MySQL services: managed and unmanaged.

  • Managed MySQL runs on a service like DigitalOcean, PlanetScale, Amazon RDS, etc
  • Unmanaged MySQL runs on a server inside your Hatchbox cluster (for free!)

Managed MySQL

To use a managed MySQL database with Hatchbox:

  • Create the database on your provider of choice
  • Add an environment variable to your app to connect to your database. Typically, DATABASE_URL for Ruby applications.

Backups, upgrades and maintenance is handled by your MySQL provider.

Unmanaged MySQL

Choose a server in your cluster and assign it the MySQL role. This will install the MySQL server package and allow you to create databases in Hatchbox.

Connecting to MySQL databases remotely

If you'd like to connect to your MySQL database from your local machine, you will need to use an SSH tunnel.

Let's use TablePlus for example:

  1. Under "Over SSH", add your server's public IP address and the "deploy" user.
  2. Check the "Use SSH key" box. Optionally, import your private key if you don't have it in your SSH config.
  3. Set the database host to "127.0.0.1" since you'll be connected over SSH.
  4. Set the username and password for your Hatchbox database.
  5. Test the connection to confirm everything works.