Working with Data in Google Cloud SQL

30 minutes
  • 7 Learning Objectives

About this Hands-on Lab

SQL databases are a foundation of computing in general, and cloud computing is no exception. Cloud SQL is a particularly robust implementation of a relational database service with rapid scalability, high availability, and secure replication. In this hands-on lab, you’ll see how to set up a Cloud SQL instance, add a MySQL database, and import the schema and data of a large dataset. Once it’s set up, you’ll run through several sample queries.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Enable APIs

Enable the Cloud SQL APIs.

Create Cloud Storage Bucket

Create a Cloud Storage bucket.

Note: The following locations are allowed in the lab: US-East-1, US-West-1, US-Central-1, Europe-West-1, and Australia-Southeast-1).

Clone a GitHub Repository and Copy to Bucket

Open the Cloud Shell, clone the GitHub repository, and copy the necessary files to the Cloud Storage bucket.

Create a Cloud SQL Instance

Create a Cloud SQL instance.

Create Database, Table, and Import Schema

Create the database, then create a table, and finally, import the schema.

Import Data

Import the MetObjects_subset.csv data.

Query Database

Connect to the database in Cloud Shell, declare the met_museum database, and query Met objects.

Additional Resources

Scenario

The team has come to you with a big project: set up a Cloud SQL instance to handle a MySQL database of over 600,000 items. After setting up the instance and the database, you’ll need to bring the relevant files into a Cloud Storage bucket so you can import the schema and populate the database. Once that has been accomplished, they want you to run a couple of sample queries to confirm that all is working properly.

To accomplish this task, you’ll need to complete the following steps:

  1. Enable necessary APIs.
  2. Create a Cloud Storage bucket.
  3. Retrieve remote files and copy to bucket.
  4. Create a Cloud SQL instance.
  5. Create a MySQL database.
  6. Import schema and data.
  7. Run test queries.

Lab Environment Requirements

When creating a MySQL instance, make sure to set the following values to avoid the lab shutting down (due to changes in GCP's default settings):

  • Select a single zone deployment (you don't need high availability for this lab)
  • In Customize your instance, choose a lightweight machine type with 1 vCPU, 3.75 GB
  • Choose 10 GB for the storage capacity

Note: The following locations are allowed in the lab: US-East-1, US-West-1, US-Central-1, Europe-West-1, and Australia-Southeast-1.

Reference Links

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?