Guided Lab: Connecting Cloud SQL Database with MySQL Workbench (Local)
Description
In this lab, you will learn how to create and configure a Google Cloud SQL MySQL database and connect to it directly from your local machine using MySQL Workbench. You will provision a Cloud SQL instance, insert sample data using Cloud SQL Studio, configure networking to authorize your local IP address, and finally verify connectivity by querying the data in MySQL Workbench.
Prerequisites
To ensure the successful completion of this lab, we highly recommend taking these guided labs to gain the necessary understanding:
Objectives
In this lab, you will:
- Create a Cloud SQL MySQL instance
- Add a user account and create a database
- Insert sample data using Cloud SQL Studio
- Configure networking to authorize your local machine’s IP address
- Connect to the Cloud SQL instance using MySQL Workbench
- Verify the data by running queries locally
Lab Steps
Create a Cloud SQL Instance
1. In the Google Cloud Console, go to SQL → Create Instance.
2. Select MySQL as the database engine.
3. Configure the instance
- Edition preset: Sandbox
- Instance ID: Enter the desired instance ID.
- Password: Set a secure password (e.g., Password@123)
- Zonal availability: Single zone
4. Leave other configurations at their default values.
5. Once done, click Create instance.
Add a User Account
1. Once the instance is created, go to the Users tab.

2. Click Add user account.
3. Enter the desired User name and Password.

3. Click Add. A confirmation message will appear in the bottom‑left corner

Create a Database
1. Navigate to the Databases tab.

2. Click Create database.
3. Enter a Database name (e.g., EmployeesDB).

4. Once done, click the Create button.
Insert Sample Data Using Cloud SQL Studio
1. Navigate to the Cloud SQL Studio tab.
2. Select the database you created (EmployeesDB).
3. Enter the credentials for the user account you added earlier.

4. Click Authenticate.
5. Once authenticated, you’ll be ready to run SQL commands in Cloud SQL Studio. Open the Untitled query editor.

6. Begin by creating a new table within the EmployeesDB database to store employee records.
Paste the following SQL command into the query editor:
CREATE TABLE Employees ( ID INT PRIMARY KEY, Name VARCHAR(50), Age INT, Salary DECIMAL(10, 2) );
Click the Run button to execute the SQL command.

This creates a table named Employees with four columns: ID, Name, Age, and Salary

7. Insert Data into the Table
INSERT INTO Employees (ID, Name, Age, Salary)
VALUES (1, 'Jose Rizal', 25, 50000.00);
INSERT INTO Employees (ID, Name, Age, Salary)
VALUES (2, 'Andres Bonifacio', 25, 50000.00);
INSERT INTO Employees (ID, Name, Age, Salary)
VALUES (3, 'Emilio Aguinaldo', 25, 50000.00);
Click the Run button to execute the SQL commands.

These statements insert three employee records into the Employees table.
8. Query the Table
Run the following SQL command:
SELECT * FROM Employees;
Click the Run button to execute the SQL command.

This retrieves all rows and columns from the Employees table, displaying the data you inserted.
Configure Networking for Local Access
1. In the Cloud SQL instance details page, go to Connections → Networking.
2. Under Authorized Networks, add the public IP address of your local machine.
- Name: Enter your desired name.
- Click Use My IP
-1-07JAN2026.png)
3. Save the configuration.
Connect Using MySQL Workbench
1. Open MySQL Workbench on your local machine.
2. Click the + icon to create a new connection.
3. Fill in the connection details:
- Connection Name: Enter your desired name.
- Hostname: Public IP of your Cloud SQL instance (e.g., 34.171.160.215)
- Port: 3306
- Username: The user you created (e.g., admin)
- Password: Click Store in Vault, then enter the password (e.g., Password@123) and
- Default Schema: EmployeesDB (optional)
-2-07JAN2026.png)
4. Click Test Connection.
5. Once successful, click OK to save the connection.
-3-07JAN2026.png)
Verify Data in Workbench
1. Open the connection you just created in MySQL Workbench.
2. Run the following query:
SELECT * FROM Employees;
3. You should see the records created earlier in Cloud SQL Studio.
-4-07JAN2026.png)
Congratulations! You have successfully created a Cloud SQL MySQL instance, added a user account, created a database, and inserted sample data using Cloud SQL Studio. You then configured networking to authorize your local IP, connected to the instance using MySQL Workbench, and verified the data. This workflow demonstrates how to integrate managed databases in Cloud SQL with local development environments, enabling you to manage and query Cloud SQL directly from your workstation.