
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create client and server VMs
/ 40
Administer your database server
/ 30
Connect to the database from a client
/ 30
In this lab, you provision a Linux virtual machine in a private network to act as a database server. You also create a virtual machine that you can use as a bastion host to connect to the database server as an administrator. You configure the database server for remote connections and add a user account. You then install the MySQL-MariaDB client software to connect to the database server from a client machine.
In this lab, you learn how to perform the following tasks:
In this task, you use Qwiklabs and perform initialization steps for your lab.
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00
), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
Open a new web browser window and navigate to the Google Cloud Console (console.cloud.google.com). Use the project selector to choose the first project with a leading name of 'qwiklabs-gcp.'
On the Navigation menu (), click Cloud overview.
In the Project info section, find your Project ID and copy and paste it into a text file. You will need it later.
Click the Activate Cloud Shell () icon in the upper right of the Console. The Cloud Shell terminal will open in a pane at the bottom of the window.
Activate the Identity-Aware Proxy API which will allow you to connect to all of the Virtual Machines created within this project without configuring SSH keys. Enter the following command in the Cloud Shell:
Type ls and you see this folder has the Terraform files completed from the last lab.
Click Open Editor, and then from the training-data-analyst/courses/db-migration/terraform-clients-servers/ folder, open the terraform.tfvars file.
Change the values in the terraform.tfvars file as noted below.
Item | Value |
---|---|
project_id | |
gcp_region_1 | |
gcp_zone_1 |
Click Check my progress to verify the objective.
When the Terraform process completes, on the Navigation menu (), click Compute Engine. Multiple machines should be listed.
Find the mysql-server- machine, and make note of its internal IP address (it is likely 10.2.2.2 or 10.2.2.3).
Click SSH for the mysql-server- machine to connect to that machine.
Type CTRL+C to end the command.
Return to the Cloud Shell Code Editor, and in the training-data-analyst/courses/db-migration/terraform-clients-servers folder, add a file called cloud-nat.tf, and then add the following Terraform code to that file:
The output will appear as follows:
Type "q" to exit.
Create a password for the root user with the following command:
The initial password will be blank.
Follow the instructions to create a password for root using a password you will remember. Select Yes to all the remaining prompts.
Log in to the database using the root account with the following command:
You need a user account to log in with from the client machine.
By default, the database server only listens for connections on the local machine. A quick fix to the configuration will change that.
Type CTRL+X to exit, and answer Y when prompted to save your changes.
To restart the database, enter the following command:
Click Check my progress to verify the objective.
To connect to the MySQL-MariaDB database from your client machine, you must install MySQL-MariaDB client software.
On the Navigation menu (), click Compute Engine. Click SSH for the mysql-client- machine to connect to that terminal.
In the new SSH window, enter the following commands to complete the installation:
Return to the Navigation menu (), click Compute Engine. Find the mysql-server- machine, and make note of its internal IP address (it is likely 10.2.2.2 or 10.2.2.3).
To connect to your database, use the following command (replace SERVERIP with the IP address you just verified):
Enter "\s" at the MariaDB prompt.
Details will be returned for the Database server.
Type exit to exit the MySQL client.
At this point, there's no database so there's nothing else to do, but you have a complete solution in place. Your database server is in a secure network with no public access. You have a Linux machine in the public network that can be used to administer the database and connect to the machine using the MySQL-MariaDB client software.
Click Check my progress to verify the objective.
Close your SSH session, and then return to the Cloud Shell terminal.
To delete everything you created earlier in the lab, enter the following command:
Congratulations! You have provisioned a Linux virtual machine in a private network to act as a database server. You also created a virtual machine that you can use as a bastion host to connect to the database server as an administrator. You configured the database server for remote connections and added a user account. You then installed the MySQL client software to connect to the database server from a client machine.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
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.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one