El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Easily Switch Between Product Types

You can click the drop-down list box to switch between different product types.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ TaurusDB/ Getting Started/ Buying a DB Instance and Connecting to It Using the mysql Client

Buying a DB Instance and Connecting to It Using the mysql Client

Updated on 2025-01-10 GMT+08:00

After buying a DB instance, you can connect to it using a Linux ECS with the mysql client installed over a private network. This section describes how to access a DB instance from an ECS using the mysql client.

Operation Process

Process

Description

Preparations

Sign up for a HUAWEI ID, enable Huawei Cloud services, make sure you have a valid payment method configured, create IAM users, and grant them specific TaurusDB permissions.

Step 1: Buy a DB Instance

Configure information required for instance creation.

Step 2: Buy an ECS

If you want to use the mysql client to connect to a DB instance, you need to prepare a server, install the mysql client on the server, and run the connection command.

Purchase a Linux ECS that is in the same region and VPC as your DB instance.

If you have purchased a Windows ECS, you can connect to the DB instance using MySQL-Front. For details, see Buying a DB Instance and Connecting to It Using MySQL-Front.

Step 3: Test Connectivity and Install the mysql Client

Test the network connectivity between the ECS and the private IP address and port of the DB instance, and install the mysql client on the ECS.

Step 4: Connect to the DB Instance Using the mysql Client

Use a command-line interface (CLI) to connect to the DB instance using the private IP address and port.

Preparations

  1. Sign up for a HUAWEI ID and enable Huawei Cloud services.
  2. Before buying DB instances, ensure that your account balance is sufficient. Top up your account if required.
  3. For fine-grained permissions management on Huawei Cloud resources, use Identity and Access Management (IAM) to create a user or user group and grant it specific operation permissions. For details, see Creating a User and Granting TaurusDB Permissions.

Step 1: Buy a DB Instance

  1. Go to the Buy DB Instance page.
  2. Configure instance information and click Next.

    Parameter

    Example Value

    Description

    Billing Mode

    Pay-per-use

    The billing mode of an instance.

    • Yearly/Monthly: A prepaid billing mode in which you pay for resources before using it. Bills are settled based on the subscription period. The longer the subscription, the bigger the discount. This mode is a good option for long-term, stable services.
    • Pay-per-use: A postpaid billing mode. You pay as you go and just pay for what you use. The DB instance usage is calculated by the second but billed every hour. This mode allows you to adjust resource usage easily. You neither need to prepare for resources in advance, nor end up with excessive or insufficient preset resources.

    Region

    AP-Singapore

    The region where an instance is located.

    NOTE:

    You cannot change the region of an instance once it is purchased.

    DB Instance Name

    Taurusdb-8293

    The DB instance name.

    DB Engine Version

    TaurusDB V2.0

    The DB engine and version.

    DB Instance Type

    Cluster

    A cluster instance can contain one primary node and up to 15 read replicas. The primary node processes read and write requests, and the read replicas process only read requests. If the primary node becomes unavailable, TaurusDB automatically fails over to a read replica. Cluster instances apply to medium- and large-sized enterprises in the Internet, taxation, banking, and insurance sectors.

    Storage Type

    DL6

    The original Shared storage. The default storage type of TaurusDB instances created before July 2024 is Shared storage, while that of TaurusDB instances created in July 2024 and beyond is DL6.

    DL6-based instances achieve zero RPO with a 3-AZ deployment and deliver better performance and higher peak throughput. They are suitable for core application systems that are sensitive to performance and have demanding requirements on storage I/O during peak hours, such as those in finance, e-commerce, government, and gaming.

    AZ Type

    Multi-AZ

    If your workloads require cross-AZ DR or are insensitive to cross-AZ latency, you are advised to deploy the primary node and read replicas in different AZs to achieve higher availability and reliability.

    Primary AZ

    AZ1

    The primary AZ of an instance.

    Time Zone

    (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi

    You need to select a time zone for your instance based on the region hosting your instance. The time zone is selected during instance creation and cannot be changed after the instance is created.

    Parameter

    Example Value

    Description

    Instance Specifications

    Dedicated

    2 vCPUs | 8 GB

    The vCPUs and memory of an instance.

    CPU Architecture

    x86

    x86 instances use Intel® Xeon® Scalable processors and feature robust and stable computing performance. When working on high-performance networks, the instances provide the additional performance and stability that enterprise-class applications demand.

    Nodes

    2

    This parameter is mandatory for cluster instances.

    Storage

    -

    It contains the system overhead required for inodes, reserved blocks, and database operations.

    Backup Space

    -

    TaurusDB provides free backup space equal to the amount of your used storage. After the free backup space is used up, you will be billed for the additional space on a pay-per-use basis.

    Parameter

    Example Value

    Description

    VPC

    default_vpc

    The virtual network in which your instance is located. A VPC can isolate networks for different workloads.

    If no VPC is available, click Create VPC. After a VPC is created, click . For details, see Creating a VPC and Subnet.

    NOTICE:

    After a TaurusDB instance is created, the VPC cannot be changed.

    Subnet

    default_subnet

    A subnet provides dedicated network resources that are logically isolated from other networks for network security.

    Security Group

    default

    The security group enhances security by controlling access to TaurusDB from other services.

    Parameter

    Example Value

    Description

    Administrator

    root

    The username of the database administrator account. The default username is root.

    Administrator Password

    -

    Must consist of 8 to 32 characters and contain at least three of the following: uppercase letters, lowercase letters, digits, and special characters (~!@#%^*-_=+?,()&$|.). Enter a strong password and periodically change it to improve security, preventing security risks such as brute force cracking.

    Keep your password secure because you cannot retrieve it from the system.

    After a DB instance is created, you can reset this password. For details, see Resetting the Administrator Password.

    Confirm Password

    -

    Enter the administrator password again.

    Parameter Template

    Default-GaussDB-for-MySQL 8.0

    A parameter template contains engine configuration values that can be applied to one or more instances.

    Table Name

    Case insensitive

    Specifies whether table names are case sensitive. This option cannot be changed later.

    • Case sensitive: Table names are case sensitive.
    • Case insensitive: Table names are case insensitive and are stored in lowercase letters by default.

    Enterprise Project

    -

    If your account has been associated with an enterprise project, select the target project from the Enterprise Project drop-down list.

    For more information about enterprise projects, see Enterprise Management User Guide.

    Tag

    -

    Tags a DB instance. This parameter is optional. Adding tags helps you better identify and manage your DB instances. Each DB instance can have up to 20 tags.

    Quantity

    1

    You can buy DB instances in batches. The default value is 1. The value ranges from 1 to 10.

  3. Check the purchased DB instance.
  4. Click the DB instance name to go to the Basic Information page.
  5. In the Network Information area, obtain the private IP address and database port.
    Figure 1 Viewing the private IP address and database port

Step 2: Buy an ECS

  1. Log in to the management console and check whether there is an ECS available.
  2. Buy an ECS and select Linux (for example, CentOS) as its OS.

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

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

  3. On the ECS Information page, view the region and VPC of the ECS.
    Figure 2 Viewing ECS information
  4. On the Basic Information page of the DB instance, view the region and VPC of the DB instance.
  5. Check whether the ECS and DB instance are in the same region and VPC.
    • If they are in the same region and VPC, go to Step 3: Test Connectivity and Install the mysql Client.
    • If they are in different regions, buy another ECS or DB instance. 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 they are in different VPCs, change the VPC of the ECS to that of the DB instance. For details, see Changing a VPC.

Step 3: Test Connectivity and Install the mysql Client

  1. Log in to the ECS. For details, see Logging In to a Linux ECS Using VNC in Elastic Cloud Server User Guide.
  2. On the ECS, check whether it can connect to the DB instance using the private IP address and port obtained in 5.
    telnet private_IP_address port
    NOTE:

    If the message "command not found" is displayed, install the Telnet tool based on the OS used by the ECS.

    • If the ECS can connect to the DB instance, no further action is required.
    • If the ECS cannot connect to the DB instance, check the security group rules.
      • If in the security group associated with the ECS, there is no outbound rule with Destination set to 0.0.0.0/0 and Protocol & Port set to All, add the private IP address and port of the DB instance to the outbound rules.
      • Add the private IP address and port of the ECS to the inbound rules in the security group associated with the DB instance.
  3. Download the mysql client installation package for the Linux ECS.

    You are advised to use a mysql client running a version later than that of the DB instance.

    wget https://dev.mysql.com/get/mysql-community-client-8.0.21-1.el6.x86_64.rpm

  4. Run the following command to install the mysql client:

    rpm -ivh --nodeps mysql-community-client-8.0.21-1.el6.x86_64.rpm

    NOTE:
    • If any conflicts occur during the installation, add the replacefiles parameter to the command and install the client again.

      rpm -ivh --replacefiles mysql-community-client-8.0.21-1.el6.x86_64.rpm

    • If a message is displayed prompting you to install a dependency package during the installation, add the nodeps parameter to the command and install the client again.

      rpm -ivh --nodeps mysql-community-client-8.0.21-1.el6.x86_64.rpm

Step 4: Connect to the DB Instance Using the mysql Client

  1. Run the following command on the ECS to connect to the DB instance:

    mysql -h <host> -P <port> -u <userName> -p

    Example:

    mysql -h 192.*.*.* -P 3306 -u root -p

    Table 1 Parameter description

    Parameter

    Description

    <host>

    The private IP address obtained in 5.

    <port>

    The database port obtained in 5. The default value is 3306.

    <userName>

    The administrator account root.

  2. Enter the password of the database account if the following information is displayed:
    Enter password:
    Figure 3 Connection succeeded
  3. Create database db_test.

    create database db_test;

    Figure 4 Creating a database
  4. Create table t_test.

    create table t_test(id int(4), name char(20), age int(4));

    Figure 5 Creating a table
  5. Insert a data record into the table.

    insert into t_test(id, name, age) values(1, 'zhangsan', 30);

    Figure 6 Inserting data
  6. Query data in the table.

    select * from t_test;

    Figure 7 Querying data
  7. Update the value of age for the data record whose id is 1 in the table.

    update t_test set age=31 where id=1;

    Figure 8 Updating data
  8. Query the updated data in the table.

    select * from t_test where id=1;

    Figure 9 Querying the updated data
  9. Delete the data record whose id is 1 from the table.

    delete from t_test where id=1;

    Figure 10 Deleting table data
  10. Delete the table structure.

    drop table t_test;

    Figure 11 Deleting a table structure
  11. Delete the database.

    drop database db_test;

    Figure 12 Deleting a database

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback