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 role command

Manage database roles for a Postgres database branch. This command is only supported for Postgres databases. Usage:

Available sub-commands

Service token automation: role

Legend: ✅ supported · Postgres only. All sub-commands require --org or PLANETSCALE_ORG.
Setup and commands to avoid: CLI overview · Service tokens

Available flags

Global flags

Examples

The create sub-command

Create a new role for a Postgres database branch: Usage:
Available flags:
  • --inherited-roles string - Comma-separated list of role names to inherit privileges from. Common values are ‘pg_read_all_data’ for read access, ‘pg_write_all_data’ for write access, and ‘postgres’ for admin access.
  • --ttl duration - TTL defines the time to live for the role. Durations such as “30m”, “24h”, or bare integers such as “3600” (seconds) are accepted. The default TTL is 0s, which means the role will never expire.
Example:

The delete sub-command

Delete a role: Usage:
Available flags:
  • --force - Delete a role without confirmation
  • --successor string - Role to transfer ownership to before deletion. Usually ‘postgres’.
Aliases: delete, rm Example:

The get sub-command

Retrieve information about a specific role: Usage:
Example:

The list sub-command

List all roles for a Postgres database branch: Usage:
Available flags:
  • -w, --web - List roles in your web browser.
Aliases: list, ls Example:

The reassign sub-command

Reassign objects owned by one role to any other role:
Be careful with this command. Reassigning objects like databases, tables, or schemas will change who is able to write to them, alter them, or delete them.
Usage:
Available flags:
  • --force - Force reset without confirmation
Example:

The renew sub-command

Renew a role’s expiration: Usage:
Example:

The reset sub-command

Reset the credentials for any API-created role:
Be careful with this command. If you are currently using the affected role’s credentials for connecting to your database, running this command will reset the password, and new connections using the old password will not work.
Usage:
Available flags:
  • --force - Force reset without confirmation
Example:

The reset-default sub-command

Reset the credentials for the default postgres role:
Be careful with this command. If you are currently using the default postgres role credentials for connecting to your database, running this command will reset the password, and new connections using the old password will not work.
Usage:
Available flags:
  • --force - Force reset without confirmation
Example:

The update sub-command

Update a role’s name: Usage:
Available flags:
  • --name string - New name for the role
Example:

Managing Postgres roles

Postgres roles API documentation

Need help?

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