Prerequisites: Service Account Setup
Use attached service accounts for secure, key-free authentication on:- GCE - VMs with attached service accounts
- GKE - Pods with Workload Identity
Create Service Account
- Go to IAM & Admin → Service Accounts
- Create service account named
bytebase - Grant roles as needed:
Cloud SQL ClientandCloud SQL Instance User- for Cloud SQLCloud Spanner Database Admin- for SpannerSecret Manager Secret Accessor- for Secret Manager
- Note the email:
bytebase@PROJECT_ID.iam.gserviceaccount.com
Attach Service Account
Option A: GCE VM- Create VM in Compute Engine
- Set service account:
bytebase@PROJECT_ID.iam.gserviceaccount.com - Set access scopes: “Allow full access to all Cloud APIs”
Alternative: Service Account Keys
- Create a service account with required roles
- Download the JSON key file
- Set environment variable:
Cloud SQL with IAM Authentication
Prerequisites: Service account with Cloud SQL roles.
Step 1: Configure Cloud SQL Instance
- In Cloud SQL, edit your instance
- Add flag:
cloudsql_iam_authentication=on - Save (SSL is enabled by default)
Step 2: Add Service Account User
Using gcloud:Step 3: Connect from Bytebase
- Click New Instance in Bytebase
- Configure connection details:
- Host: Your Cloud SQL connection name (
PROJECT_ID:REGION:INSTANCE_ID)- Find this in Cloud SQL console → Instance details
- Port: 3306 (MySQL) or 5432 (PostgreSQL)
- Username:
- MySQL:
bytebase(service account name only) - PostgreSQL:
bytebase@PROJECT_ID.iam(with project ID)
- MySQL:
- Authentication: Select
Google Cloud SQL IAM
- Host: Your Cloud SQL connection name (
- Click Test Connection then Create
Cloud Spanner
Bytebase connects to Spanner through the Google Cloud API, so the instance form has no hostname, username, or password. You identify the Spanner instance by its project ID and instance ID, and Bytebase signs in as a service account.Prerequisites: Service account with the
Cloud Spanner Database Admin role (roles/spanner.databaseAdmin).Step 1: Find the Project ID and Instance ID
Go to the Spanner Instances page in the Google Cloud console and select the project. The page lists each instance with its ID. Use the instance ID, not the display name.Step 2: Connect from Bytebase
- Go to Instances, click Connect instance, and choose Spanner.
- Enter the Project ID and Instance ID.
- Under Credential Source, choose how Bytebase signs in:
- Leave Specific Credential off to use the credentials of the Bytebase server: the file that
GOOGLE_APPLICATION_CREDENTIALSpoints to, or else the attached service account. - Turn on Specific Credential and paste the contents of the service account’s JSON key file, or drop the file onto the field. A Workload Identity Federation credential configuration file also works. Bytebase Cloud requires a specific credential.
- Leave Specific Credential off to use the credentials of the Bytebase server: the file that
- Click Test Connection, then Create.
spanner-nonprod.p.googleapis.com.
GCP Secret Manager
Store database passwords securely in Google Cloud Secret Manager instead of Bytebase.Prerequisites: Service account with
Secret Manager Secret Accessor role.Step 1: Create Secret
- Go to Secret Manager Console
- Click Create Secret
- Enter secret name (e.g.,
db-password) and your database password as value - Click Create and note the resource name:
projects/PROJECT_ID/secrets/SECRET_NAME
Step 2: Configure in Bytebase
- In your database instance settings, find the password field
- Click the key icon to use external secret
- Select GCP Secret Manager
- Enter the secret resource name from Step 1
- Test connection and save
Private IP and VPC Peering
For Cloud SQL instances using private IP:Step 1: Configure VPC Peering
- Enable Service Networking API
- Reserve IP range for services:
- Create private connection:
Step 2: Connect from Bytebase
- Deploy Bytebase in the same VPC or a peered VPC
- Use the private IP address for the Cloud SQL instance
- Configure connection as normal with private IP
Database-Specific Configuration
This page covers what is specific to GCP. For the privileges the Bytebase user needs, TLS, and the other connection settings, see the page for your engine:- PostgreSQL, for Cloud SQL for PostgreSQL and AlloyDB
- MySQL, for Cloud SQL for MySQL
Best Practices
- Use Service Accounts over Keys: Always prefer attached service accounts
- Enable Private IP: Use VPC peering for enhanced security
- Use Secret Manager: Centralize password management
- Follow Least Privilege: Grant only necessary IAM roles
- Enable Audit Logging: Monitor database access with Cloud Audit Logs
Troubleshooting
Connection Refused
- Verify Cloud SQL instance allows connections from your IP/network
- Check authorized networks configuration
- Ensure VPC peering is properly configured for private IP
IAM Authentication Failed
- Verify service account has
Cloud SQL Instance Userrole - Check database user was created with correct type
- Ensure
cloudsql_iam_authenticationflag is enabled
Secret Manager Access Denied
- Verify service account has
Secret Manager Secret Accessorrole - Check secret resource name is correct
- Ensure secret exists in the correct project
Private IP Connection Issues
- Verify VPC peering is active
- Check firewall rules allow traffic
- Ensure Bytebase is deployed in the correct VPC

