Overview
In this tutorial, you will:
-
Instantiate a new MySQL instance
-
Set up and query a database
-
Clean up the instance
Project setup
Google Cloud Platform resources are organised into projects. Cloud SQL needs a project to get started.
Select a project, or
Create SQL instance
You can create a MySQL instance using the UI.
-
Navigate to the SQL Instances page
-
Click on
-
Choose a database engine:
Verify is selected and click the button.
-
Choose a MySQL instance type:
Click
-
Configure instance:
The default configuration should be sufficient. Remember these values, you'll reference them later:
-
or choose
-
Click
Connect to the SQL instance
The gcloud CLI is used to interface with the instance. This tool comes pre-installed in the web console shell.
Open Cloud Shell by clicking the button in the navigation bar in the upper-right corner of the console.
Use this command to connect to the instance:
Using the SQL instance
Within theMySQL
prompt, run the following:
-
Create database and table
sql CREATE DATABASE geography; USE geography; CREATE TABLE cities (city VARCHAR(255), country VARCHAR(255));
-
Insert data
sql INSERT INTO cities (city, country) values ("San Francisco", "USA"); INSERT INTO cities (city, country) values ("Beijing", "China");
-
Query
sql SELECT * FROM cities;
You should see the following query results:
SELECT * FROM cities; +---------------+---------+ +---------------+---------+ +---------------+---------+
Cleanup
You'll need to clean up the newly created resources.
-
Navigate to the SQL instances page.
-
Click on the link to go to the details page.
-
Click