Connecting to a DB Instance Using a MariaDB Client
You can connect to a DB instance through a Secure Sockets Layer (SSL) connection or a non-SSL connection. SSL encrypts connections to your DB instance, making in-transit data more secure.
Prerequisites
- You have logged in to an ECS.
- For details on how to create and log in to an ECS, see Purchasing an ECS and Logging In to an ECS.
- To connect to a DB instance through an ECS, you must ensure that:
- The ECS and DB instance are in the same VPC.
- The ECS is allowed by the security group to access the DB instance.
- If the security group associated with the DB instance is the default security group, you do not need to configure security group rules.
- If the security group associated with the DB instance is not the default security group, check whether the security group rules allow the ECS to connect to the DB instance. For details, see Configuring Security Group Rules.
If the rules allow the access from the ECS, you can connect to the DB instance through the ECS.
If the rules do not allow the access from the ECS, you need to add a security group rule allowing the ECS to access the DB instance.
- You have installed a database client to connect to DB instances.
You can use a database client to connect to the target DB instance in Linux or Windows.
- In Linux, install a MariaDB client on a device that can access RDS. It is recommended that you download a MariaDB client running a version later than that of the DB instance.
- In Windows, you can use any common database client to connect to the target DB instance in a similar way.
Connecting to a DB Instance Using Commands (SSL Connection)
- Log in to the management console.
- Click in the upper left corner and select a region and a project.
- Click in the upper left corner of the page and choose Databases > Relational Database Service.
- On the Instances page, click the instance name to go to the Basic Information page.
- In the DB Information area, check whether SSL is enabled.
- 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.
- Import the root certificate ca.pem to the Linux or Windows. For details, see How Can I Import the Root Certificate to a Windows or Linux OS?
- Connect to the RDS for MariaDB instance. In Linux, for example, run the following command:
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>
Floating IP address. To obtain this parameter value, go to the Basic Information page of the DB instance. You can find the floating IP address in the Connection Information area.
<port>
Database port. By default, the value is 3306. To obtain this parameter value, go to the Basic Information page of the DB instance. You can find the database port in the Connection Information area.
<userName>
Database account used for logging in to the DB instance. The default value is root.
<caName>
Name of the CA certificate. The certificate should be stored in the directory where the command is executed.
- Enter the password of the database account if the following information is displayed:
Enter password:
Figure 1 Connection example
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot