Here is a handy Cloud SQL for MySQL Qwik Start Tutorial. Our Google Cloud Support team is here to help you with your questions and concerns.
Cloud SQL for MySQL: Qwik Start Guide
Starting a Google Cloud lab and signing into the Google Cloud console is as easy as 1-2-3.
With these steps, you will have your lab up and running in no time:
- Start the Lab & Sign In to Google Cloud Console
- How to Activate Cloud Shell
- How to Create a Cloud SQL Instance
- How to Connect to Instance Using the MySQL Client in Cloud Shell
- How to Create a Database and Upload Data
Start the Lab & Sign In to Google Cloud Console
- First, click the Start Lab button. If the lab requires payment, a pop-up will take you to the available payment methods.
On the left, we will see the Lab Details panel, which includes:
- The Open Google Cloud Console button
- Time remaining for the lab
- Temporary credentials needed for the lab
- Additional information to guide us through the lab
- Then, click “Open Google Cloud Console”. In case we are using Chrome, we can use the “Open Link in Incognito Window” option as well.
- Now, the lab will set up resources and open a new tab with the Sign-In page.
Our experts recommend arranging the tabs in separate windows side-by-side for better visibility.
In case you see the “Choose an account” dialog box, click the “Use Another Account” option.
- Next, copy the Username from the Lab Details panel and paste it into the Sign-In dialog.
- Then, click Next and copy the Password from the Lab Details panel, and paste it into the Welcome dialog. Now, click Next.
- Now, click through the following pages as indicated below:
- Accept the terms and conditions
- Skip recovery options and two-factor authentication
- Avoid signing up for free trials
- Then, the Google Cloud console will open in the tab.
We can view the list of Google Cloud products and services via the Navigation menu.
How to Activate Cloud Shell
Cloud Shell is a VM loaded with development tools. It comes with a persistent 5GB home directory and runs on Google Cloud. Also, it offers command-line access to our Google Cloud resources.
We can activate it by clicking the “Activate Cloud Shell” option at the top of the Google Cloud console. Once connected, we will be authenticated, and the project will be set to our `PROJECT_ID`. The output will contain a line declaring the `PROJECT_ID` for this session:
Your Cloud Platform project in this session is set to “PROJECT_ID”
We can also opt to list the active account name with:
gcloud auth list
Then, click “Authorize”.
Furthermore, we can list the project ID with:
gcloud config list project
How to Create a Cloud SQL Instance
- First, go to the Navigation menu and click SQL.
- Then, click “Create Instance”.
- Next, select MySQL as the database engine.
- After that, enter `newinstance` as the Instance ID.
- Then, click the “Generate” link in the password field. We can view the password by clicking the eye icon. Remember to save the password for later use.
- Now, choose “MySQL 8” as the database version.
- After that, select “Enterprise edition” as the Cloud SQL edition.
- Then, choose “Development” (4 vCPU, 16 GB RAM, 100 GB Storage, Single zone) for Preset.
- Now, set the Region as desired.
- Furthermore, set the Multi zones (Highly available) > Primary Zone field as desired.
- Finally, click “Create Instance”.
It may take a few minutes for the instance to be created. Once completed, a green checkmark will appear next to the instance name. Click on the Cloud SQL instance to open the SQL Overview page.
We can also click “Check my progress” to verify this task.
How to Connect to Instance Using the MySQL Client in Cloud Shell
- First, go to the Cloud Console and click the “Cloud Shell” icon.
- Then, click Continue.
- Now, connect to the Cloud SQL instance by running this command at the Cloud Shell prompt:
gcloud sql connect myinstance –user=root
- Then, click Authorize.
- After that, enter the root password when prompted and press Enter.
- We will now see the MySQL prompt.
How to Create a Database and Upload Data
- First, run this command to create a SQL database called `customerdetails` on the Cloud SQL instance:
CREATE DATABASE customerdetails;>code>
- At this point, we can click “Check my progress” to verify the task.
- Now, it is time to insert sample data into the `customerdetails` database:
USE customerdetails;
CREATE TABLE entries (
customerName VARCHAR(255),
phoneNo VARCHAR(255),
entryID INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(entryID)
);
INSERT INTO entries (customerName, phoneNo) VALUES ("John Doe", "+1 601 967-0379");
INSERT INTO entries (customerName, phoneNo) VALUES ("Charlie Brown", "+1 480 424-7816");
- We can easily retrieve the data: with SELECT * FROM commad.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
With the above steps, we can easily start a lab, sign in to the Google Cloud console, create a Cloud SQL instance, connect to it, and manage a database.
In brief, our Support Experts demonstrated how to set up Cloud SQL for MySQL on Google Cloud with Qwik Start.
0 Comments