Connecting to a DB Instance Using a MariaDB Client
You can connect to an instance through a non-SSL connection or an SSL connection using a MariaDB client. SSL encrypts connections to your DB instance and is more secure.
Prerequisites
- An EIP has been bound to the target DB instance and security group rules have been configured. The operations are as follows:
- Bind an EIP to your DB instance.
For details about how to bind an EIP, see Binding an EIP.
- Obtain the IP address of the ECS you use to connect to the DB instance.
- Configure security group rules.
Add the IP address obtained in 1.b and the DB instance port to the inbound rule of the security group.
For details about how to configure a security group rule, see Configuring Security Group Rules.
- Run the ping command to check the connectivity between the ECS and the EIP that has been bound to the DB instance in 1.a.
- Bind an EIP to your 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, you need to install a MariaDB client on your device. 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.pemTable 1 Parameter description Parameter
Description
<host>
EIP of the DB instance to be connected.
<port>
Port of the DB instance to be connected.
<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
If the connection fails, ensure that preparations have been correctly made in Prerequisites and try again.
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