Getting Started with CloudSQL
Create a Cloud SQL instance
- From the Navigation menu () click on SQL.
- Click Create Instance.
- Create your instance with the following settings:
- Click choose MySQL
- Type “myinstance” for Instance ID
- In the password field click on the Generate link and the eye icon to see the password. Save the password to use in the next section.
- Leave all other fields at the default values.
- Click Create Instance.
After a few minutes the instance is created and you can continue to the next section. If it seems to be taking a long time, refresh your browser.
Connect to your instance using the mysql client in Cloud Shell
- In the Cloud Console, click the Cloud Shell icon in the upper right corner.
- Click Continue.
- At the Cloud Shell prompt, connect to your Cloud SQL instance by running the following:
gcloud sql connect myinstance --user=root
Click Authorize.
- Enter your root password when prompted.
- Press the Enter key when you’re done typing.
Create a database and upload data
- Create a SQL database called
guestbook
on your Cloud SQL instance: - 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;
Tag:Google Cloud