Halaman ini belum tersedia dalam bahasa lokal Anda. Kami berusaha keras untuk menambahkan lebih banyak versi bahasa. Terima kasih atas dukungan Anda.

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

Connecting to a DB Instance from a Linux ECS

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.

  1. Purchasing an ECS
  2. Querying the Private IP Address of the DB Instance to Be Connected
  3. Testing Connectivity and Installing a MySQL Client
  4. Using CLI to Connect to a DB Instance

Purchasing an ECS

  1. Log in to the management console and check whether there is an ECS available.

    Figure 1 Viewing ECSs

  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 GaussDB(for MySQL) DB instance for mutual communication.

    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 basic information

  4. On the Basic Information page of the GaussDB(for MySQL) DB instance, view the region and VPC of the DB instance.

    Figure 3 Viewing instance basic information

  5. Check whether the ECS and GaussDB(for MySQL) DB instance are in the same region and VPC.

    • If yes, query the private IP address of the DB instance to be connected.
    • If no, purchase another ECS or DB instance. If the ECS and DB instance are in different regions, they 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.

Querying the Private IP Address of the DB Instance to Be Connected

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click in the upper left corner of the page, choose Databases > GaussDB(for MySQL).
  4. On the Instances page, click the instance name to go to the Basic Information page.
  5. In the Network Information area, obtain the private IP address and database port.

    Figure 4 View the private IP address and database port

Testing Connectivity and Installing a MySQL Client

  1. Log in to the ECS. For details, see Login Using VNC in the Elastic Cloud Server User Guide.
  2. Check whether the private IP address and database port of the DB instance (obtained in Querying the Private IP Address of the DB Instance to Be Connected) can be connected to the ECS.

    telnet private IP address port

    Example:

    telnet 192.168.0.16 3306
    NOTE:

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

    • If yes, network connectivity is available.
    • If no, check the security group rules.
      • If Destination is not 0.0.0.0/0 and Protocol & Port is not All on the Outbound Rules page of the ECS, add the private IP address and port of the DB instance to the outbound rules.
        Figure 5 Configuring rules of an ECS security group
      • To view the inbound rules of the GaussDB(for MySQL) security group, add the private IP address and port of the ECS to the inbound rules. For details, see Configuring Security Group Rules.

  3. Download the MySQL client installation package for Linux locally. A MySQL client running a version later than that of the DB instance is recommended.

    Find the link to the required version on the download page. The mysql-community-client-8.0.21-1.el6.x86_64 is used as an example.

    Figure 6 Downloading a MySQL client

  4. Upload the installation package to the ECS.
  5. Use any terminal connection tool, such as WinSCP and PuTTY, to upload the installation package to the ECS.
  6. Run the following command to install the MySQL client:

    rpm -ivh 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. Example:

      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, you can add the nodeps parameter to the command and install the client again. Example:

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

Using CLI to Connect to a DB Instance

In Linux, use a MySQL client to connect to your instance through an SSL connection or non-SSL connection. The SSL connection encrypts data and is more secure.

  • SSL Connection (Recommended)
    1. Log in to the management console.
    2. Click in the upper left corner and select a region and a project.
    3. Click in the upper left corner of the page, choose Databases > GaussDB(for MySQL).
    4. On the Instances page, click the instance name to go to the Basic Information page.
    5. In the DB Instance Information area, check whether SSL is enabled next to the SSL field.
      • If SSL is enabled, go to 6.
      • If SSL is disabled, click . In the displayed dialog box, click Yes to enable SSL. Then go to 6.
    6. Click next to the SSL field to download Certificate Download.zip, and extract the root certificate ca.pem and bundle ca-bundle.pem from the package.
    7. Upload ca.pem to the ECS.
    8. Run the following command on the ECS to connect to the DB instance:

      mysql -h <host> -P <port> -u <userName> -p --ssl-ca=<caName>

      Example:

      mysql -h 172.16.0.31 -P 3306 -u root -p --ssl-ca=ca.pem

      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.

      <caName>

      Name of the CA certificate. The certificate should be stored in the directory where the command is executed.

    9. Enter the password of the database account if the following information is displayed:
      Enter password:
  • Non-SSL Connection
    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.168.0.16 -P 3306 -u root -p

      Table 2 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 7 Connection succeeded

Kami menggunakan cookie untuk meningkatkan kualitas situs kami dan pengalaman Anda. Dengan melanjutkan penelusuran di situs kami berarti Anda menerima kebijakan cookie kami. Cari tahu selengkapnya

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback