Help Center/ Relational Database Service_RDS for MariaDB/ Getting Started/ Example: Buy and Connect to an RDS for MariaDB Instance
Updated on 2025-06-24 GMT+08:00

Example: Buy and Connect to an RDS for MariaDB Instance

This example illustrates how to purchase an RDS for MariaDB instance and connect to it from a Linux ECS over a private network.

Figure 1 Example diagram

Step 1: Buy an RDS for MariaDB Instance

  1. Go to the Buy DB Instance page.
  2. Click the Custom Config tab and configure instance parameters. Then, click Buy. Keep the region, AZ, VPC, and security group of the DB instance the same as those of the ECS.
    Figure 2 Basic information

    Figure 3 Instance specifications

    Figure 4 Basic settings and connectivity

  3. View the purchased RDS instance.

Step 2: Buy an ECS

  1. Go to the Elastic Cloud Server console.
  2. Check whether there is a Linux ECS.
    • If yes, go to 3.
    • If no, purchase an ECS and select Linux (for example, CentOS) as its OS.

      To download a MariaDB client to the ECS, bind an EIP to the ECS. The ECS must be in the same region, VPC, and security group as the RDS for MariaDB instance for mutual communications.

      For details about how to purchase a Linux ECS, see Purchasing an ECS in Elastic Cloud Server User Guide.

      Figure 5 ECS
  3. Check whether the ECS and RDS for MariaDB instance are in the same region and VPC.
    • If they are not in the same region, purchase another ECS. The ECS and DB instance in different regions cannot communicate with each other. To reduce network latency, deploy your DB instance in the region nearest to your workloads.
    • If the ECS and DB instance are in different VPCs, change the VPC of the ECS to that of the DB instance. For details, see Changing a VPC.

Step 3: Connect to the RDS for MariaDB Instance

  1. Use a Linux remote connection tool (for example, MobaXterm) to log in to the ECS. Enter the EIP bound to the ECS for Remote host.
    Figure 6 Creating a session
  2. Enter the password of the ECS.
    Figure 7 Entering the password
    Figure 8 Successful login
  3. Install a MariaDB client by following the instructions provided in the official documentation.

    In CentOS, for example, run the following statement:

    yum install MariaDB-client
    Figure 9 Installing the client
  4. Connect to the RDS for MariaDB instance.
    mysql -h <host> -P <port> -u <userName> -p
    Table 1 Parameter description

    Parameter

    Description

    <host>

    On the Instances page, click the instance name to go to the Overview page. Choose Connectivity & Security from the navigation pane. In the Connection Information area, obtain the floating IP address and database port of the DB instance.

    The default port is 3306.

    <port>

    <userName>

    Enter the administrator account root.

    Figure 10 Connection successful
  5. Create a database, for example, mydb.
    create database mydb;
    Figure 11 Creating a database
  6. Create a table, for example, my_table.
    create table my_table(id int);
    Figure 12 Creating a table