Make sure to first set up your PlanetScale developer environment. Once you've installed the
pscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.
This command opens a secure MySQL shell instance to your database so that you can manipulate it from the command line.
It uses the MySQL command line client (
mysql), which must be installed prior to use.
pscale shell <DATABASE_NAME> <BRANCH_NAME> <FLAG>
If no branch is specified, you'll be prompted to enter one. If only one branch exists on the database, you can leave off
|View help for |
|Local address to bind and listen for connections. By default, the proxy binds to |
|The organization for the current user|
|PlanetScale database remote network address. By default, the remote address is automatically populated from the PlanetScale API.|
|Define the access level with a role|
Available roles for the
--role flag are:
|The API token to use for authenticating against the PlanetScale API.|
|The base URL for the PlanetScale API. Default is |
|Config file. Default is |
|Enable debug mode.|
|Show output in a specific format. Possible values: |
|Disable color output.|
|The service token for authenticating.|
|The service token ID for authenticating.|
pscale shell <DATABASE_NAME> <BRANCH_NAME>
Once the shell is opened, you can run SQL as expected.
DATABASE_NAME/BRANCH_NAME >DATABASE_NAME/BRANCH_NAME > show tables;+---------------+| Tables_in_db |+---------------+| users |+---------------+DATABASE_NAME/BRANCH_NAME > exit;
exit to exit the shell.