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
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 a MySQL Client

Buying a DB Instance and Connecting to It Using a MySQL Client

Updated on 2024-09-05 GMT+08:00

You can connect to your DB instance using a Linux ECS with a MySQL client installed over a private network. This section describes how to access a GaussDB(for MySQL) instance from an ECS using a standard MySQL client.

Step 1: Buy a DB Instance

Step 2: Buy an ECS

Step 3: Test Connectivity and Install a MySQL Client

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

Step 1: Buy a DB Instance

  1. Go to the Buy DB Instance page.
  2. Configure instance information and click Next.
    Figure 1 Selecting a DB engine version

    Figure 2 Selecting specifications
    Figure 3 Configuring a network
    Figure 4 Setting a password
  3. Check the purchased DB instance.
    Figure 5 Purchase succeeded
  4. Click the DB instance name to enter the Basic Information page.
  5. In the Network Information area, obtain the private IP address and database port.
    Figure 6 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 a 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 7 Viewing basic information about the ECS
  4. On the Basic Information page of the DB instance, view the region and VPC of the DB instance.
    Figure 8 Viewing basic information about 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 a 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 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 a 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 of the ECS, there is no outbound rule with Destination set to 0.0.0.0/0 and Protocol & Port set to All, add an outbound rule for the private IP address and port of the DB instance.
      • On the Inbound Rules page of the DB instance security group, add an inbound rule for the private IP address and port of the ECS.
  3. Download the MySQL client installation package for the Linux ECS.

    A MySQL client running a version later than that of the DB instance is recommended.

    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 try to 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>

    Private IP address obtained in 5.

    <port>

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

    <userName>

    Administrator account root.

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

    create database db_test;

    Figure 10 Creating the database
  4. Create table t_test.

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

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

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

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

    select * from t_test;

    Figure 13 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 14 Updating data
  8. Query the updated data in the table.

    select * from t_test where id=1;

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

    delete from t_test where id=1;

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

    drop table t_test;

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

    drop database db_test;

    Figure 18 Deleting the database

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback