gcloud sql instances execute-sql adds user and secret-version options
Introduced 2026-06-30 · score 0.97
HOW TO USE IT
To execute SQL with password authentication, pass the database user and Secret Manager password version to `gcloud sql instances execute-sql`.
gcloud sql instances execute-sql <INSTANCE> --sql='<SQL_STATEMENT>' --database=<DATABASE> --user=<USER> --password-secret-version=projects/<PROJECT>/locations/<LOCATION>/secrets/<SECRET>/versions/<SECRET_VERSION>WHY THIS HELPS
Execute SQL against a Cloud SQL instance using a user and password secret version.
REQUIREMENTS AND LIMITATIONS
- INSTANCE (required): Cloud SQL instance ID.
- --sql (required): SQL statement(s) to execute; multiple statements are supported.
- --database: Database on which to execute the statement.
- --user: Database user to authenticate as; used together with `--password-secret-version`.
- --password-secret-version: Secret Manager resource name holding the user's password; used together with `--user`. Expected format: `projects/{project}/locations/{location}/secrets/{secret}/versions/{secret_version}`.
- Prerequisite: Configure the database user and permissions according to the Cloud SQL Data API instructions before executing statements.
- Prerequisite: The password secret must be regional and stored in the same region as the Cloud SQL instance.
FIRST-PARTY EVIDENCE
- https://docs.cloud.google.com/sdk/docs/release-notes#57500_2026-06-30
- https://docs.cloud.google.com/sdk/gcloud/reference/sql/instances/execute-sql
- https://docs.cloud.google.com/sql/docs/mysql/executesql-instance?hl=en
Check the installed version and the source before using it. Entry JSON