This topic describes how to connect to an RDS for MySQL instance. After completing the initial configuration, you can connect to your RDS instance from an ECS instance or your computer.
For information about how to create accounts and databases in other DB engines, see the following resources:
- Create an RDS for SQL Server instance
- Connect to an RDS for PostgreSQL instance
- Connect to an RDS for PPAS instance
- Connect to an RDS for MariaDB instance
After you create an instance, configure a whitelist, and create an account, you can use DMS, a database client, or CLI to connect to your RDS instance. You can also set the IP address, port, and account information in applications to connect.
Use DMS to connect to an RDS instance
DMS is a graphical data management service provided by Alibaba Cloud. It can be used to manage non-relational databases and relational databases, and supports data and schema management, user authorization, security audit, data trends, data tracking, BI charts, and performance and optimization.
For more information, see Use DMS to log on to an RDS instance.
Use a database client to connect to an RDS instance
ApsaraDB RDS for MySQL is fully compatible with MySQL. You can connect to an RDS instance from any general-purpose database client in the similar way you connect to a MySQL database. This section describes how to use HeidiSQL to connect to an RDS instance.
- Start HeidiSQL.
- In the lower-left area of the Session manager dialog box, click New.
- Enter the information of the RDS instance to be connected. The following table describes
Parameter Description Network type The method of connecting to the RDS instance. Select MariaDB or MySQL (TCP/IP). Hostname/IP Enter the private or public IP address of the RDS instance.
You can obtain the private and public IP addresses of the RDS instance by completing the following steps:
- If your database client is deployed in an ECS instance that is in the same region and has the same network type as the RDS instance, you can use the private IP address of the RDS instance. For example, if the ECS and RDS instances are both in a VPC located in the China (Hangzhou) region, then you can use the private IP address of the RDS instance to create a secure, efficient connection.
- In the other situations, use the public IP address of the the RDS instance.
- Log on to the RDS console.
- In the upper-left corner of the page, select the region where the RDS instance is located.
- Find the RDS instance and click its ID.
- On the displayed Basic Information page, find the private and public IP addresses and their corresponding port numbers.
User The username of the account that you use to access the RDS instance. Password The password of the account that you use to access the RDS instance. Port The port for the RDS instance to establish a connection. If you use the private IP address of the RDS instance to establish a connection, enter the private port number. If you use the public IP address of the RDS instance to establish a connection, enter the public port number.
- Click Open.
If the entered information is correct, the RDS instance can be connected.
Use the CLI to connect to an RDS instance
If MySQL is installed on your server, you can use the CLI to connect to an RDS instance as follows:
mysql -h<Host name> -P<Port number> -u<Username> -p<Password> -D<RDS instance name>
|-h||The private or public IP address of the RDS instance. For more information, see Configure endpoints.||
|-P||The port for the RDS instance to establish a connection.
|-u||The username of the account that you use to access the RDS instance.||
|-p||The password of the account that you use to access the RDS instance.
Note This field is optional.
|-D||The name of the RDS instance you want to access.