arrow_back

Cloud SQL for PostgreSQL: Qwik Start

Join Sign in

Cloud SQL for PostgreSQL: Qwik Start

30 minutes 1 Credit

GSP152

Google Cloud Self-Paced Labs

Overview

In this lab you'll learn how to create and connect to a Google Cloud SQL PostgreSQL instance and perform basic SQL operations using the Cloud Console and the psql client.

Setup and Requirements

Qwiklabs setup

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

What you need

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
  • Time to complete the lab.

Note: If you already have your own personal Google Cloud account or project, do not use it for this lab.

Note: If you are using a Chrome OS device, open an Incognito window to run this lab.

How to start your lab and sign in to the Google Cloud Console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is a panel populated with the temporary credentials that you must use for this lab.

    Open Google Console

  2. Copy the username, and then click Open Google Console. The lab spins up resources, and then opens another tab that shows the Sign in page.

    Sign in

    Tip: Open the tabs in separate windows, side-by-side.

  3. In the Sign in page, paste the username that you copied from the left panel. Then copy and paste the password.

    Important: You must use the credentials from the left panel. Do not use your Google Cloud Training credentials. If you have your own Google Cloud account, do not use it for this lab (avoids incurring charges).

  4. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Cloud Console opens in this tab.

Create a Cloud SQL instance

Click on the menu icon in the top left of the screen to see the Navigation menu.

742dc285f86cdd1f.png

In the left menu of the Console, click on SQL.

780d772292fb4b06.png

Click Create Instance.

Click choose PostgreSQL.

Create your instance with the following settings:

  • Enter myinstance for Instance ID.
  • Enter a password for the postgres user. Save or remember this password, you'll need it in the next section.

instance_info.png

Leave the default values for the other fields.

Click Create.

You are returned to the instances list. Your new instance is greyed out while it initializes and starts.

After a few minutes your instance is created and you can continue to the next section. If it seems to be taking a long time refresh your browser.

Test Completed Task

Click Check my progress to verify your performed task. If you have completed the task successfully you will granted with an assessment score.

Create a Cloud SQL instance

Test your Understanding

Below are multiple choice questions to reinforce your understanding of this lab's concepts. Answer them to the best of your abilities.

Connect to your instance using the psql client in the Cloud Shell

In the Cloud Console, click the Cloud Shell icon in the upper right corner.

55efc1aaa7a4d3ad.png

Then click "Start Cloud Shell".

At the Cloud Shell prompt, connect to your Cloud SQL instance by running:

gcloud sql connect myinstance --user=postgres

Enter your postgres password. Note: The cursor will not move. Press Enter when you're done typing.

You should now see the psql prompt.

Upload data into the postgres database

Insert sample data into the postgres database:

CREATE TABLE guestbook (guestName VARCHAR(255), content VARCHAR(255), entryID SERIAL PRIMARY KEY); INSERT INTO guestbook (guestName, content) values ('first guest', 'I got here!'); INSERT INTO guestbook (guestName, content) values ('second guest', 'Me too!');

Retrieve the data:

SELECT * FROM guestbook;

You should now see:

guestname | content | entryid --------------+-------------+--------- first guest | I got here! | 1 second guest | Me too! | 2 (2 rows) postgres=>

You have created a Google Cloud SQL PosgreSQL instance and connected to it.

Test your Understanding

Below are multiple choice questions to reinforce your understanding of this lab's concepts. Answer them to the best of your abilities.

Congratulations!

Finish Your Quest

41ab6fa0d099216d.png cloudsql-quest-badge.png

Continue your Quest with Baseline: Deploy & Develop or Cloud SQL. A Quest is a series of related labs that form a learning path. Completing this Quest earns you the badge above, to recognize your achievement. You can make your badge (or badges) public and link to them in your online resume or social media account. Enroll in Baseline: Deploy & Develop or Cloud SQL and get immediate completion credit if you've taken this lab. See other available Qwiklabs Quests.

Next Steps / Learn More

This lab is also part of a series of labs called Qwik Starts. These labs are designed to give you a little taste of the many features available with Google Cloud. Search for "Qwik Starts" in the lab catalog to find the next lab you'd like to take!

Google Cloud Training & Certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated May 12,2022
Lab Last Tested May 12,2022

Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.