Relational Database Service (MySQL)

Step 3: Connect the MySQL instance through the Intranet

2023-12-05 07:16:55

Two connection methods are available to connect instances through the MySQL client: General connection and SSL connection. Among them, SSL connection features data encryption and higher security.

  • General Connection

Using the MySQL client to connect the MySQL instance is the same as connecting general MySQL.

1. Log in to ECS

2. Connecting MySQL Instance

Open the command line input window and execute the following command to connect the MySQL instance.

MySQL -h<host_name> -P8635 -u<User> -p<Password>

Parameter Descriptions:

-h: Server IP, that is, the "connection address" of the server in the instance list corresponding to the cluster on the Instance Management page of the RDS.

-P: Database port, that is, the database port on the Instance Info page.

-u: Username, that is, MySQL account (the default administrator account is root).

-p: Password, that is, the password of the database account and the password specified when creating a database instance.

Example:

mysql -h 172.16.0.31 -P 8635 -u root –p’RDSpwd@4321’

  • SSL Connection

Step 1. Log in to the Console.

Step 2. Click  in the upper left corner of the Console and select a Region and a Project.

Step 3. Select Database > RDS. Go to the RDS information page.

Step 4. On the Instance Management page, click the instance name to go to the Basic Info page, and in SSL in the Database Info module, click the download icon to download the root certificate or bundle.

Step 5. Import the root certificate into the ECS Linux operating system.

  • A new root certificate with a validity period of 20 years was provided by the RDS in April 2017. The certificate will take effect after an instance is restarted. Please replace the original root certificate with the certificate issued by the authorized organization in time before the original root certificate expires to improve the system security.

  • The RDS also enables users to download the root certificate bundle containing the new root certificate issued in April 2017 and the original root certificate.

Step 6. Connect the RDS instance. Taking Linux OS as an example, execute the following command.

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

Table 1-10 Parameter descriptions

Parameters

Descriptions

<hostName>

Intranet address Intranet Address in the Connection Info module on the Basic Info page of the target instance.

<port>

Database port, 13049 by default. Database Port in the Connection Info module on the Basic Info page of the target instance.

<userName>

Username, that is, RDS account (the default administrator account is root).

<caName>

The file name of the SSL certificate. This file should be placed under the path where the command is executed.

The following example shows how to connect the database instance through SSL connection using the root user.

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

Enter the password when the following message displays:

Enter password:


tBz9.ETenkk2