You can connect to a DB instance through a non-SSL connection or an SSL connection. The SSL connection encrypts data and is more secure.
If the security group rules allow the access from the ECS, the ECS can connect to the DB instance.
If the security group rules do not allow the access from the ECS, you need to add a security group rule. The ECS must be allowed by the security group to access the DB instance.
You can use a database client to connect to the target DB instance in the Linux or Windows OS.
For details about how to obtain and install the MySQL client, see section How Can I Install the MySQL Client?
The database client MySQL-Front is used as an example in Using MySQL-Front to Connect to a DB Instance.
Parameter |
Description |
---|---|
Name |
Indicates the name of the database connection task. If you do not set this parameter, it will be the same as the Host value by default. |
Host |
Indicates the floating IP address of the DB instance to be connected. To view the floating IP address and port of the DB instance, perform the following steps:
|
Port |
Indicates the private network port of the DB instance. |
User |
Indicates the name of the user who will access the DB instance. The default user is root. |
Password |
Indicates the password of the RDS database account. |
If the connection fails, see What Should I Do If an ECS Cannot Connect to an RDS DB Instance Through a Private Network?
For details, see section How Can I Identify the Validity Period of an SSL Root Certificate?
mysql -h <host> -P <port> -u <userName> -p --ssl-ca=<caDIR>
Parameter |
Description |
---|---|
<host> |
Floating IP address. To obtain this parameter, go to the Basic Information page of the DB instance and view the floating IP address in the Connection Information area. |
<port> |
Database port. By default, the value is 3306. To obtain this parameter, go to the Basic Information page of the DB instance and view the database port in the Connection Information area. |
<userName> |
Username of the RDS database account. The default administrator is root. |
<caDIR> |
Directory of the CA certificate. The certificate should be stored in the directory where the command is executed. |
For example, to connect to a DB instance through an SSL connection as user root, run the following command:
mysql -h 172.16.0.31 -P 3306 -u root -p --ssl-ca=ca.pem
Enter the password of the database account if the following information is displayed:
Enter password:
If the connection fails, see What Should I Do If an ECS Cannot Connect to an RDS DB Instance Through a Private Network?