Documentation

Connect to the Database With MySQL CLI

Here's a few steps for connecting to your project's database via MySQL's CLI tool.

Note: If you're looking to import data, we'd recommend taking a look at the Import Database documentation.

1. Start an SSH Tunnel #

  1. Go to your project's Access Control page.

  2. Create a new SSH Session. You can read more about SSH Sessions here.

  3. In the "SSH Connection" section, select an environment and check the "Include database port forward" option.

  4. Copy the supplied SSH Connection string into a terminal on your local machine.

    Run it to open an SSH connection with an included port forward for the database.

2. Connect to the Database #

  1. Install the MySQL Client on your local machine if it isn't already.

  2. Go to your project's Access Control page.

  3. Copy the "MySQL CLI" command from the "Database Connection" section.

  4. Open up your terminal.

  5. You're now connected to your database. ✅ Watch what you delete now!

3. Navigating the Database #

Here's a few commands that you might find useful whilst connected via the MySQL CLI:

  • show databases - list all databases
  • use <database name> - connect to a specific database
  • show tables - list all tables
  • show processlist - view a summary of the queries that are currently running
  • show full processlist - view a full list of the queries that are currently running