Ends in
00
hrs
00
mins
00
secs
SHOP NOW

⏲️ 48-Hour Bonus Sale - Get 25% OFF any product. Use Coupon code: TD-NY2026

Back to Course

GCP PlayCloud Labs

0% Complete
0/0 Steps
  1. GCP PlayCloud Labs
  2. Guided Lab: How to Launch a GCP Compute Engine Linux Instance
  3. Guided Lab: Creating a VM Using Instance Templates
  4. Guided Lab: Creating and Managing Instance Groups in Compute Engine
  5. Guided Lab: Creating a Spot VM Instance
  6. Guided Lab: Configuring Shielded VM Options
  7. Guided Lab: Exploring Instance Metadata in Google Cloud
  8. Guided Lab: Vertically Scaling a VM Instance
  9. Guided Lab: Setting up a Web Server on a VM Instance
  10. Guided Lab: Using Startup Scripts in GCP VM Instances
  11. Guided Lab: Creating a Custom Image from a VM Instance with Web Server in Google Cloud
  12. Guided Lab: Setting Up and Managing a Database on a VM Instance
  13. Guided Lab: Installing WordPress on an Ubuntu VM Instance with LEMP Stack
  14. Guided Lab: Reserving or Promoting a Static IP Address for a VM Instance
  15. Guided Lab: SSH Access to GCP VM Instance from Local Machine using SSH Key Pair
  16. Guided Lab: Guarding Your VM with Deletion Protection
  17. Guided Lab: Creating a Cloud Storage Bucket
  18. Guided Lab: Hosting a Static Website in Google Cloud Storage Bucket
  19. Guided Lab: Protecting Data on Cloud Storage Bucket Against Accidental Delete and Overwrite Using Object Versioning
  20. Guided Lab: Using Cloud Storage Lifecycle Rules to Automate Object Management
  21. Guided Lab: Managing Cloud Storage Buckets via SSH Commands
  22. Guided Lab: Creating a Cloud SQL Instance
  23. Guided Lab: Running SQL Commands in Cloud SQL Studio
  24. Guided Lab: Creating and Restoring Cloud SQL Backups
  25. Guided Lab: Integrating Cloud SQL Database instance with a VM instance
  26. Guided Lab: Connecting Cloud SQL Database with MySQL Workbench (Local)
  27. Guided Lab: Guarding Your Cloud SQL Instances with Deletion Protection
  28. Guided Lab: Creating a Cloud NAT Gateway
  29. Guided Lab: Creating a Google Kubernetes Engine (GKE) Cluster
  30. Guided Lab: Connecting to a Kubernetes Engine Cluster
  31. Guided Lab: Deploying a Simple Web Application on GKE
  32. Guided Lab: Creating a Custom Virtual Private Cloud (VPC)
  33. Guided Lab: Establishing VPC Peering for Secure Cross‑Network Communication
  34. Guided Lab: Configuring Firewall Rules to Secure and Access a VM
  35. Guided Lab: Deploying a LAMP Stack on a Compute Engine VM
Lesson 26 of 35
In Progress

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: IDNameAge, 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

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)

4. Click Test Connection.

5. Once successful, click OK to save the connection.

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.

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.

Skip to content