Dynamic Database Credentials
This feature is currently available only to customers participating in a Private Preview. If you'd like to participate and be among the first to try this feature, ask our support or account team for details.
A dynamic database secret creates a temporary database account each time you mint a credential from it, and drops the account when the lease ends. Read Dynamic Secrets first for the prerequisites and how leases work.
Supported Databases
| Database | targetType
|
Notes |
|---|---|---|
| MySQL | mysql
|
The database field is optional. |
| Microsoft SQL Server | mssql
|
SQL Server on premises, on a virtual machine, or Azure SQL Managed Instance. Azure SQL Database isn't supported. The database field is required. |
| PostgreSQL | postgres
|
The administrator account must be a superuser, so managed services that don't offer superuser, such as Amazon RDS for PostgreSQL, Azure Database for PostgreSQL flexible server, and Google Cloud SQL for PostgreSQL, aren't supported. The database field is required. |
Step 1: Write the Base Secret
The base secret holds the administrator account and tells the engine how to reach the database.
| Field | Description |
|---|---|
type
|
Required. Set to database. |
targetType
|
Required. mysql, mssql, or postgres, in lowercase. It can't change after you create the base secret. |
connection
|
Required. host is a DNS name or IP address that the engine can reach. port is a number from 1 to 65535, not a string. connection takes only these two fields. |
database
|
The database the temporary accounts work in. Required for SQL Server and PostgreSQL. For PostgreSQL, it's also the database the administrator connects to. For MySQL, leave it out to give Read and ReadWrite accounts access to every database on the server except the mysql system database. |
siteId
|
Required in practice. The ID of the engine site whose engine creates and removes the accounts, at the top level of the base secret. A base secret without it is accepted, but every mint from it fails with 400 secret_target_type_invalid. |
credential
|
Required. The administrator account, as {"authMechanism": "usernamePassword", "username": "...", "password": "..."}. authMechanism must be usernamePassword. |
The base secret takes only these fields. A field it doesn't define, such as siteId inside connection, is refused with 400.
System databases can't be used: mysql, sys, information_schema, and performance_schema for MySQL; master, model, msdb, and tempdb for SQL Server; template0 and template1 for PostgreSQL.
The CLI can't write base secrets, so this example writes a MySQL base secret through the REST API, using the TENANT and TOKEN variables from Authenticating to the API. Build the body with jq so that special characters in the password are escaped correctly:
base=$(jq -n --arg pw "$MYSQL_ADMIN_PASSWORD" --arg site "$SITE_ID" '{
type: "database",
targetType: "mysql",
connection: {host: "mysql01.corp.example.com", port: 3306},
database: "orders",
siteId: $site,
credential: {authMechanism: "usernamePassword", username: "ws_admin", password: $pw}
}')
curl -sS -X POST "https://$TENANT/workload-secrets/api/v1/secrets/base/dynamic/base/orders-mysql" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d "$base"
The body is the definition itself, with no data wrapper. To rotate the administrator password or change the host, port, database, or site later, send the same request again to the same path with the complete definition. Each write stores a new version. See Creating a Dynamic Secret.
Step 2: Write the Dynamic Secret
The dynamic secret points to the base secret and sets what the credential can do and the lease length. Set type to database, and set access, which is required, to an access level or to explicit grants. Write it through the API, as for the base secret:
curl -sS -X POST "https://$TENANT/workload-secrets/api/v1/secrets/dynamic/payments/prod/orders-db-read" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{
"type": "database",
"baseSecretPath": "dynamic/base/orders-mysql",
"access": {"type": "level", "level": "read"},
"ttlSeconds": 900
}'
Workload Secrets Vault checks the definition against the base secret when you write it. The base secret must already exist.
For an access level, set access to {"type": "level", "level": "<value>"} with one of these values. The values are case-sensitive, so Read isn't accepted.
| Access level | level value |
Can |
|---|---|---|
| Read | read
|
Read data |
| ReadWrite | readWrite
|
Read, insert, update, and delete data |
| Admin | admin
|
Everything the administrator account can do, server-wide |
Read and ReadWrite accounts can't change the schema, run stored routines, manage accounts, or read the server's account and credential tables.
To name the exact privileges instead, on MySQL or PostgreSQL, use explicit grants. See Explicit Grants. SQL Server takes access levels only.
Step 3: Mint a Credential
delinea --json workload secret mint payments/prod/orders-db-read
{
"data": {
"leaseId": "862f1d20-35ae-4518-9539-0b07c975f8c0",
"expiresAt": "2026-11-05T18:21:23.8904094+00:00",
"credential": {
"type": "database",
"username": "mint_e61e896fdb7",
"password": "Wm9y8kJ0cX1vR2t6aGJ3eUlxQ2xNcE9h"
}
}
}
The account name is at .data.credential.username and the password at .data.credential.password. Each mint creates a new account. See Minting a Credential.
Temporary account names start with mint_, followed by 11 random characters. In MySQL, the account is created for any host ('mint_...'@'%').
What Each Access Level Grants
| Level | MySQL | SQL Server | PostgreSQL |
|---|---|---|---|
| Read | SELECT on the database, or on every database except mysql when no database is set |
A database user in the db_datareader role |
CONNECT on the database, and SELECT on the tables and sequences in every non-system schema |
| ReadWrite | SELECT, INSERT, UPDATE, and DELETE, with the same scope as Read |
The db_datareader and db_datawriter roles |
Read, plus INSERT, UPDATE, and DELETE on tables, and USAGE and UPDATE on sequences |
| Admin | ALL PRIVILEGES on every database, even when a database is set |
A login in the sysadmin server role |
A superuser role |
-
MySQL: Read and ReadWrite credentials turn on the
partial_revokesserver setting withSET PERSIST. The setting stays on after the credential is removed, and it changes how MySQL interprets wildcard characters in database-level grants for the whole server. Review this with your database administrator before you use dynamic credentials on a shared server. -
PostgreSQL: Read and ReadWrite credentials get access to the tables and sequences that exist when the credential is created. Clients must support SCRAM-SHA-256 authentication.
Explicit Grants
On MySQL and PostgreSQL, you can name the privileges a credential gets instead of using an access level. Set access to {"type": "grants", "grants": [...]}. Each grant is {"privileges": [...], "on": {"database": "...", "schema": "...", "table": "..."}}, where schema and table are optional.
This MySQL example grants SELECT, INSERT, and DELETE on the items table, and CREATE and DROP on the orders database:
curl -sS -X POST "https://$TENANT/workload-secrets/api/v1/secrets/dynamic/payments/prod/orders-db-items" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{
"type": "database",
"baseSecretPath": "dynamic/base/orders-mysql",
"access": {
"type": "grants",
"grants": [
{"privileges": ["SELECT", "INSERT", "DELETE"], "on": {"database": "orders", "table": "items"}},
{"privileges": ["CREATE", "DROP"], "on": {"database": "orders"}}
]
},
"ttlSeconds": 900
}'
On PostgreSQL, a grant on a table also names its schema:
curl -sS -X POST "https://$TENANT/workload-secrets/api/v1/secrets/dynamic/payments/prod/orders-pg-lines" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{
"type": "database",
"baseSecretPath": "dynamic/base/orders-postgres",
"access": {
"type": "grants",
"grants": [
{"privileges": ["SELECT", "INSERT"], "on": {"database": "orders", "schema": "public", "table": "lines"}}
]
}
}'
Grants follow these rules:
-
Grants: From 1 to 32 grants. Each grant names at least one privilege, in uppercase, such as
SELECT, and doesn't name the same privilege twice. -
Database:
on.databaseis required. If the base secret names a database, every grant must name the same database. On MySQL, a grant can't name a system database:mysql,sys,information_schema, orperformance_schema. -
Schema: PostgreSQL only. The schema can't be
information_schemaor start withpg_. MySQL grants don't take a schema. -
Table: A grant on a table allows only
SELECT,INSERT,UPDATE, andDELETE. On PostgreSQL, it also needs a schema. -
Names: A database, schema, or table name starts with an ASCII letter or an underscore, contains only ASCII letters, digits, underscores, and
$, and is at most 63 characters long. A database name can also contain hyphens. -
Fields: A field that a grant doesn't define, such as a misspelled
table, is refused rather than ignored.
Each privilege applies at these levels:
| Privilege | MySQL | PostgreSQL |
|---|---|---|
SELECT, INSERT, UPDATE, DELETE |
Every table in the database, or one table | Every table in every non-system schema, every table in one schema, or one table |
CREATE
|
The database | The database, or one schema |
ALTER, DROP, INDEX |
The database | Not accepted |
CONNECT, TEMPORARY |
Not accepted | The database only |
USAGE
|
Not accepted | Every non-system schema, or one schema |
A grant reaches the narrowest level its on names. For example, on PostgreSQL, USAGE with no schema applies to every non-system schema, and with a schema, to that schema only.
-
Checked again at each mint: Grants are checked against the base secret's current version every time you mint. If the base secret has changed so that a grant no longer fits, for example it now names another database, the mint returns
400secret_definition_invalidand no account is created. -
MySQL: Grants turn on the
partial_revokesserver setting withSET PERSIST, as Read and ReadWrite credentials do. See What Each Access Level Grants. -
PostgreSQL: Grants cover only the tables that exist when the credential is minted, and grant nothing on sequences.
-
SQL Server: Grants aren't supported. Writing a dynamic secret with grants for a SQL Server base secret returns
400secret_definition_invalid.
Rights the Administrator Account Needs
| Database | Rights |
|---|---|
| MySQL | Create users and grant the privileges of each access level you use. To remove accounts and end their sessions: CREATE USER, PROCESS, SELECT on performance_schema, and CONNECTION_ADMIN or SUPER. ALL PRIVILEGES ON *.* with grant option covers everything. |
| SQL Server | ALTER ANY LOGIN, ALTER ANY USER, permission to add members to db_datareader and db_datawriter, VIEW SERVER STATE, and ALTER ANY CONNECTION. For Admin credentials, membership in sysadmin. Membership in sysadmin covers everything. |
| PostgreSQL | SUPERUSER, for every access level |
Connection Security
-
MySQL: The engine uses TLS when the server offers it. To make sure the administrator connection is always encrypted, require TLS on the server.
-
SQL Server: The connection is encrypted and the server certificate is validated, so the server must present a certificate that the engine host trusts.
-
PostgreSQL: The connection is encrypted. The server certificate isn't validated.
What Happens When a Lease Ends
-
MySQL: The account is dropped and its open sessions are ended.
-
SQL Server: The login is disabled, its sessions are ended, and the database user and login are dropped.
-
PostgreSQL: The role loses its login, its sessions are ended, objects it created are reassigned to the administrator account, and the role is dropped.