This document describes how to create context sets in Cloud SQL for MySQL Studio using a context set file. Context set names must be unique within a database.
To learn about context sets, see Context sets overview .Before you begin
Complete the following prerequisites before creating an agent.
Enable required services
Enable the following services for your project:Prepare a Cloud SQL instance
- Make sure that you have access to an existing Cloud SQL instance or create a new one. For more information, see Create instances for Cloud SQL .
- Ensure that you create a database in your instance where you will create the tables. For more information, see Create a database on the Cloud SQL instance .
Required roles and permissions
- Add an IAM user or service account at the instance level. For more information, see Add an IAM policy binding to a user, service account, or group .
- Grant the
cloudsql.studioUser,cloudsql.instanceUser, andgeminidataanalytics.queryDataUserroles to the IAM user or service account at the project level. For more information, see Add IAM policy binding for a project . - You must have a privileged user grant database privileges to
the IAM user or service account.
GRANT SELECT PRIVILEGES ON * TO " IAM_USERNAME ";.
For more information, see Grant database privileges to an individual IAM user or service account .
Grant executesql
permission to Cloud SQL instance
To grant the executesql
permission to Cloud SQL instance and enable the Cloud SQL
Data API, run the following command: gcloud config set project PROJECT_ID gcloud components update gcloud beta sql instances patch INSTANCE_ID --data-api-access=ALLOW_DATA_API
-
PROJECT_ID: The ID of your Google Cloud project. -
INSTANCE_ID: The ID of your Cloud SQL instance.
Create a context set
To create a context set, perform the following steps:
-
In the Google Cloud console, go to the Cloud SQL page.
-
Select an instance from the list.
-
In the navigation menu, click Cloud SQL Studio.
-
Sign in to Studiousing IAM authentication.
-
In the Explorer pane, next to Context sets, click View actions.
-
Click Create context set.
-
In Context set name, provide a unique context set name. The context set name is case-sensitive and can contain letters, numbers, hyphens, and underscores.
-
Optional. In Context set description, add a description for your context set.
-
Click Create.
Build context sets
After creating a context set, follow the steps in Build contexts using Gemini CLI to create a context set file. You can then edit your context set to upload the context set file.
Edit a context set
To edit a context set, perform the following steps:
-
In the Google Cloud console, go to the Cloud SQL page.
-
Select an instance from the list.
-
In the navigation menu, click Cloud SQL Studio.
-
Sign in to Studiousing Identity and Access Management authentication.
-
In the Explorer pane, next to Context sets, click View actions.
-
Click Edit context set.
-
Optional: Edit Context set description.
-
Click Browsein the Upload context set filesection, and select the context set file.
-
Click Save.
Delete a context set
To delete a context set, perform the following steps:
-
In the Google Cloud console, go to the Cloud SQL page.
-
Select an instance from the list.
-
In the navigation menu, click Cloud SQL Studio.
-
Sign in to Studiousing Identity and Access Management authentication.
-
In the Explorer pane, next to Context sets, click View actions.
-
Click Delete context set.
-
In the Delete context setconfirmation dialog, enter the name of the context set.
-
Click Confirmto delete the context set.
What's next
- Learn more about context sets .
- Learn how to test a context set .
- Learn how to build contexts using Gemini CLI .

