Skip to main content

Getting Started

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.

Postgres

Create role credentials with pscale role, then connect using a connection string.pscale connect is not supported.

Vitess / MySQL

Create a branch password with pscale password, then connect with a connection string or pscale connect.

The password command

Manage database passwords for a Vitess database branch. This command is only supported for Vitess databases. To manage a role for Postgres, see the role command. Usage:
pscale password <SUB-COMMAND> <FLAG>

Available sub-commands

Sub-commandSub-command flagsProductDescription
create <DATABASE_NAME> <BRANCH_NAME> <PASSWORD_NAME>--ttl, --roleVitessCreate new credentials to access a branch’s data
delete <DATABASE_NAME> <BRANCH_NAME> <PASSWORD_ID>--forceVitessDelete the specified branch credentials
list <DATABASE_NAME> <BRANCH_NAME>--webVitessList all credentials of a database

Service token automation: password

Legend: ✅ supported · Vitess only. All sub-commands require --org or PLANETSCALE_ORG.
Sub-commandEnv-var auth--service-token flagRequires --orgPostgres / Vitess--format jsonAPI equivalent
list <database> <branch>Vitesspscale api organizations/<org>/databases/<database>/branches/<branch>/passwords --format json
createVitessPOST pscale api organizations/<org>/databases/<database>/branches/<branch>/passwords --format json
deleteVitessDELETE pscale api organizations/<org>/databases/<database>/branches/<branch>/passwords/<id> --format json
export PLANETSCALE_ORG="<org>"
pscale password list <database> <branch> --format json
Setup and commands to avoid: CLI overview · Service tokens The value <PASSWORD_ID> represents the ID number of the set of credentials. To find all available credentials and their IDs, run pscale list <DATABASE_NAME> <BRANCH_NAME>.

Sub-command flag descriptions

Some of the sub-commands have additional flags unique to the sub-command. This section covers what each of those does. See the above table for which context.
Sub-command flagDescriptionApplicable sub-commands
--ttlTTL defines the time to live for the password in seconds. By default, it is 0, which means it will never expire.create
--role <ROLE>Add a role to a passwordcreate
--forceDelete a password without confirmation.delete
--webPerform the action in your web browserlist
Available roles for the --role flag are:
  • reader
  • writer
  • readwriter
  • admin

Available flags

FlagDescription
-h, --helpView help for password command
--org <ORGANIZATION_NAME>The organization for the current user

Global flags

CommandDescription
--api-token <TOKEN>The API token to use for authenticating against the PlanetScale API.
--api-url <URL>The base URL for the PlanetScale API. Default is https://api.planetscale.com/.
--config <CONFIG_FILE>Config file. Default is $HOME/.config/planetscale/pscale.yml.
--debugEnable debug mode.
-f, --format <FORMAT>Show output in a specific format. Possible values: human (default), json, csv.
--no-colorDisable color output.
--service-token <TOKEN>The service token for authenticating.
--service-token-id <TOKEN_ID>The service token ID for authenticating.

Examples

The delete sub-command

Delete a password from a database branch: Command:
pscale password delete <DATABASE_NAME> <BRANCH_NAME> <PASSWORD_ID>
Output:
? Please type <DATABASE_NAME>/<BRANCH_NAME>/<PASSWORD_ID> to confirm:
Password <PASSWORD_ID> was successfully deleted from <BRANCH_NAME>.

Need help?

Get help from the PlanetScale Support team, or join our Discord community to see how others are using PlanetScale.