CloudSQL for MySQL


The instance ID is the name of the instance. It is used to uniquely identify your instance within the project

Connect to your instance with instance ID myinstance:

gcloud sql connect myinstance --user=root

Create a SQL database called guestbook on your Cloud SQL instance:

CREATE DATABASE guestbook;

Insert the following sample data into the guestbook database:

USE guestbook;
CREATE TABLE entries (guestName VARCHAR(255), content VARCHAR(255),
    entryID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(entryID));
    INSERT INTO entries (guestName, content) values ("first guest", "I got here!");
INSERT INTO entries (guestName, content) values ("second guest", "Me too!");

Now retrieve the data:

SELECT * FROM entries;

Switch Database in a session: