Default role
The defaultpostgres
role is similar to the Postgres superuser
, but with fewer permissions. It is defined by the following statement:
Managing roles
You should not connect to the database from your application servers using the default role. If you ever need to rotate your default role credentials and you use the default role to connect to your application, you will have to take some downtime while rotating the credentials. Instead, we recommend creating additional roles for this purpose. There are several options:- Using the
CREATE ROLE
command as the default role (which has elevated privileges). - Using the Postgres Roles API
- Using “Roles” section in your database settings
- Using the PlanetScale CLI
pscale role
commands
Creating roles via settings
To create a new role via your database settings, first select the database you want to create a role for, then navigate to “Settings” and then “Roles.” On this page, you will see all roles created via this settings page and the API. It will not show roles created manually viaCREATE ROLE
commands.

- Which branch you want this role to be created for
- The name of the role
- The permissions for this role



Creating roles via the CLI
You can also manage roles directly from the command line using the PlanetScale CLI. This provides a convenient way to create, list, and manage roles as part of your development workflow or automation scripts.Prerequisites
Make sure you have the [PlanetScale CLI installedAvailable commands
Create a new role:Creating roles via CREATE ROLE
When you create a role via the Postgres CREATE ROLE
command, these will not display on your database settings. It is up to you to manage these via the psql
CLI.
PlanetScale’s routing layer uses the user
to identify which database or branch we are sending queries to. For example, the user matt.nk35mx55qq
routes to the PlanetScale database with branch id nk35mx55qq
. When you create a new role, you do not need to specify the branch id on the user. You can simply set the user to matt
.
However, when you connect, you must append the branch id to the user so we know which branch to route to.
1
From the PlanetScale organization dashboard, select the desired database
2
Select the desired branch from the dropdown
3
Click “Connect”
4
Copy the branch id
5
Append it to your user with
.branch_id