Skip to main content
To interact with PlanetScale and manage your databases, you can use the pscale CLI to do the following:
  • Create, delete and list your databases and branches
  • Run non-interactive SQL for agents and scripts (pscale sql)
  • Open a secure MySQL or PostgreSQL shell instance
  • Manage your deploy requests
  • Bootstrap AI agents (pscale agent-guide)
  • …and more!

Install pscale

Install or upgrade the PlanetScale CLI for macOS, Linux, or Windows.
Agents and automation should start with the Agent setup prompt or pscale agent-guide --format json. Agent automation commands require pscale 0.292.0 or later; run brew upgrade pscale if agent-guide is unknown. Always pass --format json in automation.
pscale can use the MySQL command-line client to quickly open an interactive shell for a database branch. Optional instructions for installing the MySQL client can be found for each platform below.

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.

Available Commands

Use pscale [command] [command] to start up the pscale CLI in your terminal.

Flags

You may use the following flags with the PlanetScale CLI commands.

Service tokens permissions

A complete list of access permissions available for use with service tokens can be found in the PlanetScale API documentation.

Service token automation

Running pscale in CI or an AI agent uses a service token instead of pscale auth login. Provide the token as environment variables (recommended) or as flags on each command; both are equivalent:
A service token has no active organization, so resource commands need the org supplied explicitly. Set it with PLANETSCALE_ORG, the --org flag on the subcommand, or pscale org switch <org> (which works with a service token):
--org goes on the resource subcommand (database, branch, sql, api, …), never on root pscale. pscale --org <org> database list fails with unknown flag: --org.
Per-command-family matrices (env-var auth, --service-token flag, required --org, Postgres/Vitess, --format json, API equivalent): org · service-token · database · branch · role · password.

Commands to avoid under a service token

Do not retry these with service-token auth. The failure is by design, not transient. This is the most common cause of agent retry loops.
pscale org show prints not authenticated yet. Please run 'pscale auth login' under a valid service token. This is the no-current-org state, not an auth failure. Do not respond by running pscale auth login. Discover the org with pscale org list and pass it with --org or PLANETSCALE_ORG.
pscale auth check --format json confirms a token is wired up. Expect "authenticated": true, "auth_method": "service_token", and (until an org is set) an action_required status with a NO_ORG issue and a non-zero exit code. Resolve it by passing --org/PLANETSCALE_ORG on your commands.

pscale api fallback for hard-to-parse output

When a command’s human output is hard to parse, prefer --format json, or drop to the raw API with pscale api, which returns the API response verbatim and uses the same token:

Need help?

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