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 #
-
Go to your project's Access Control page.
-
Create a new SSH Session. You can read more about SSH Sessions here.
-
In the "SSH Connection" section, select an environment and check the "Include database port forward" option.
-
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 #
-
Install the MySQL Client on your local machine if it isn't already.
-
Go to your project's Access Control page.
-
Copy the "MySQL CLI" command from the "Database Connection" section.
-
Open up your terminal.
-
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