Quickly Build a Relational Database Through RDS
1. Experiment overview
1.1 Key points
This experiment is designed to build a relational database through RDS. RDS for MySQL is used as an example. After completing this experiment, you will learn the following skills:
- Basic concepts about RDS
- How to set an RDS whitelist
- How to create an RDS database
- How to create an RDS account
- How to remotely connect to an RDS instance
- How to run simple SQL commands
1.2 Procedure
- Set up experimental environment
- Set RDS whitelist
- Acquire RDS Internet address
- Create RDS account
- Create RDS database
- Log in RDS Instance and run execution
1.3 Cloud resources
- RDS instance: MySQL 5.6
- ECS instance: Ubuntu 16.04.2 LTS
1.4 Prerequisites
- An Alibaba Cloud account has been assigned automatically.
- An RDS instance has been created automatically.
1.5 Hint
When you enter the ECS console, the default region area may be different because of the different network addresses of your logon location. If you find that the resource automatically created in the document does not exist at the console interface, please manually switch to the United States - Silicon Valley’s region, you will find them there.
If you encounter some differences between the real experimental environment and the captured pictures in the lab manual, it may be caused by cloud portal version difference, which does not have a great impact on your experimental experience. You can click comment to give feedback to us. We will update the document in time. Thank you for your cooperation.
2. Experiment instructions
2.1 Start the experiment environment
Click Start Lab in the upper right corner of the page to start the experiment.
.
After the experiment environment is successfully started, the system has deployed resources required by this experiment in the background, including the ECS instance, RDS instance, Server Load Balancer instance, and OSS bucket. An account consisting of the username and password for logging on to the Web console of Alibaba Cloud is also provided.

After the experiment environment is started and related resources are properly deployed, the experiment starts a countdown. You have two hours to perform experimental operations. After the countdown ends, the experiment stops, and related resources are released. During the experiment, pay attention to the remaining time and arrange your time wisely. Next, use the username and password provided by the system to log on to the Web console of Alibaba Cloud and view related resources:

Go to the logon page of Alibaba Cloud console.

Fill in the sub-user account and click Next.

Fill in the sub-user password and click Log on.

After you successfully log on to the console, the following page is displayed.

Go to the RDS management page:

Select the US (Silicon Valley) area, you can see that an rds instance is being created, please wait a few minutes.

Wait until the RDS instance is successfully created:

2.2 Set a whitelist
Add the ECS intranet IP address to the RDS whitelist.


Add the IP address of the ECS instance to the RDS whitelist.


Click Create Whitelist.

Click Loading ECS Inner IP.

Set the name to “labex”.


Now you can view the intranet IP address of the RDS instance.

title: Whether to add an RDS whitelist
name: v1_40
2.3 Switch network type
Since the ECS instance is in the VPC network and the RDS instance is in the classic network, the two instances cannot communicate directly over the intranet address.
To make ECS instance and RDS instance intranet accessable to each other, we need to switch RDS’s network type from Classic Network to VPC. We will swtich RDS to the same VPC network as the ECS instance so that ECS can use its intranet address to connect to and manage RDS instances. With above steps done, we will not longer need to apply for RDS’s internet access.
Then switch the network mode to VPC network:


Select the default VPC network and start switching:

Wait a moment and switch is complete.

At this point, the RDS is in the same VPC network as the ECS instance. They can communicate through the intranet address.
title: Whether to switch RDS network type
name: v2_40
2.4 Create a database and an account
Refer to the figure below and click Create Database.

Refer to the figure below to set the database name, click Create.

Created successfully.

Refer to the figure below and click Create Account.

Refer to the following to set the account name and password.
Account information
Username: rds_admin
Password: Aliyun-test

Click OK.

Created successfully.

title: Whether to create RDS database and account
name: v3_40
2.5 Remotely connect to the RDS instance
Click Elastic Computer Service, as shown in the following picture.

We can see one running ECS instance in the US West 1 region. Click it to go to the ECS console as shown in the following figure.

Copy this ECS instance’s Internet IP address and remotely log on to this ECS (Ubuntu system) instance. For details of remote login, refer to login。

The default account name and password of the ECS instance:
Account name: root
Password: nkYHG890..
Run the following commands:
apt-get update
apt-get install mysql-client -y
Remote connection command:
mysql -urds_admin -p -h YOUR-INTRANET-ADDRESS-OF-RDS -P3306
Password: Aliyun-test

2.6 Add data
Run SQL statements to create data tables and add instance data. Note that every SQL statement ends with a semicolon (;).
View the current database:
show databases;

The name of the created database labex is returned. Select labex
and create a data table:
use labex;
create table user (id int, name char(11));
A data table named “user” is created in labex
.

Insert a test data record and query the data in the data table:
insert into user values (1, 'aliyun');
select * from user;

This completes the creation and usage of an RDS for MySQL database.
Reminder:
Before you leave this lab, remember to log out your Alibaba RAM account before you click the ‘stop’ button of your lab. Otherwise you’ll encounter some issue when opening a new lab session in the same browser:

3. Experiment conclusion
This experiment is designed to build a relational database through RDS. RDS for MySQL is used as an example. The process of building the relational database is summarized as follows:
- Create an RDS instance
- Set a whitelist
- Apply for an Internet address
- Create an account and a database
- Remotely log on to the RDS instance
- Run SQL commands in the RDS instance
The building process is simple. I hope you can understand the knowledge points in this experiment.