After you create an ApsaraDB RDS for MySQL instance and a database, you must manually connect to the RDS instance to manage data or connect your application server to the database for service deployment. This topic describes how to log on to an RDS instance by using Data Management (DMS) or connect to the RDS instance by using the CLI or a client. You can select a logon or connection method based on your business requirements.
Billing rules
After you create an RDS instance, you are charged for the instance specifications and the storage capacity of the RDS instance. The fees that are generated for the RDS instance vary based on the billing method, RDS edition, instance type, storage type, and storage capacity. For more information, see Billable items.
In the topic, the fees do not include the fees for the application server and third-party client that are used to connect to the RDS instance.
Preparations
You must create an RDS instance, a MySQL database on the RDS instance, and a privileged account for the RDS instance. For more information, see Step 1: Create an ApsaraDB RDS for MySQL instance and configure databases.
ImportantIn this topic, you can use the RDS instance, database, and account that are created and configured in Step 1: Create an ApsaraDB RDS for MySQL instance and configure databases. You can also modify the configurations based on your business requirements.
If you want to use DMS to log on to the RDS instance, you can skip the Preparations section.
If you want to use the CLI or a client to log on to the RDS instance, you must configure an IP address whitelist for the RDS instance and obtain the internal endpoint or public endpoint of the RDS instance based on the connection type. The following section describes the detailed operations.
Method 1: Log on to the RDS instance in the DMS console
DMS is a one-stop data management platform that allows you to manage data throughout its lifecycle. You can use DMS to manage global data assets, govern data, design and develop databases, integrate data, develop data, and consume data. These features help enterprises obtain value from data in an efficient and secure manner and facilitate the digital transformation of enterprises. For more information, see What is DMS?
You can use DMS to log on to your RDS instance to manage and use data without the need to configure IP address whitelists or connection types for the RDS instance.
Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which your RDS instance resides, find the RDS instance, and then click the instance ID.
On the page that appears, click Log In to go to the logon page of the DMS console.
In the Log On to Database Instance dialog box, enter the logon information and click Login.
Configure the Access Mode parameter. In this topic, Account + password login is selected.
Configure the Database Account and Database Password parameters. In this topic, a privileged account named
dbuser
and a custom password are used.Configure the Control Mode parameter. In this topic, Flexible Management is selected.
NoteIf your RDS instance is managed in Flexible Management mode, you can use DMS to manage the instance free of charge. If your RDS instance is managed in Stable Change or Security Collaboration, fees are generated. For more information, see Pricing.
Compared with the Flexible Management mode, the Stable Change and Security Collaboration modes provide more features and enhanced database management capabilities. If your RDS instance is for trial use, we recommend that you select Flexible Management. For more information, see Control modes.
View a database. In the left-side navigation pane of the DMS console, choose Database Instances > Instances Connected to view the created database. In this topic, the
db_test1
database is displayed. You can also double-click your database.Noteinformation_schema, mysql, performance_schema, sys, and __recycle_bin__ are system databases.
If the RDS instance exists but you cannot find the required database, the metadata may not be synchronized. To find the required database, move the pointer over the RDS instance to which the required database belongs and click the refresh icon next to the instance name.
Method 2: Use the CLI to connect to the RDS instance
If you want to use server commands to manage a database and you want to connect to the database from an ECS instance or an on-premises device, you can use the CLI to connect to the RDS instance on which the database is created. In this topic, a Linux operating system is used to describe how to use the CLI to connect to an RDS instance.
Before you can use the CLI to connect to an RDS instance, you must configure an IP address whitelist for the RDS instance and obtain the endpoint of the RDS instance based on your business requirements.
Before you can use the CLI to connect to an RDS instance, you must install MySQL on the application server. The commands that you can use to install MySQL vary based on the Linux distributions.
CentOS
sudo yum install mysql
Ubuntu
sudo apt-get update sudo apt install mysql-server
Log on to the application server to which you want to connect the RDS instance. You can connect to the RDS instance from the on-premises device or an ECS instance. For more information about how to log on to an ECS instance, see Follow the wizard to complete the configurations to purchase an ECS instance.
Run the command for database connection, enter the password, and then connect to the RDS instance. In this example, the following command is used. In the command,
h
specifies the endpoint of the RDS instance,P
specifies the port number of the RDS instance,u
specifies the username of your database account, andp
specifies the password of the database account. The password is required after you run the command# Command template mysql -hEndpoint of the RDS instance -PPort number-uUsername -p # Sample command mysql -hrm-bp**************.mysql.rds.aliyuncs.com -P3306 -udbuser -p
Specify the endpoint. You must determine whether the RDS instance can be connected over an internal network based on your business requirements and specify the required endpoint. In this topic, an internal endpoint is used. For more information about how to determine whether an RDS instance can be connected over an internal network and how to obtain the internal or public endpoint, see Preparations.
Specify the port. In this topic, port
3306
is used.Specify the username. In this topic, a privileged account named
dbuser
is used.Press the Enter key, enter the password of the privileged account in Enter password, and then run the command for database connection.
If the information similar to the following figure is displayed on the CLI, the RDS instance is connected. Then, you can perform subsequent operations.
Method 3: Use a client to connect to the RDS instance
If you are unfamiliar with complex server commands, you can also use a common third-party client to connect to the RDS instance. In this topic, MySQL Workbench 8.0.29 is used as an example to describe how to connect to an RDS instance from a client.
To connect to an RDS instance from a client, you must configure an IP address whitelist for the RDS instance and obtain the endpoint of the RDS instance based on your business requirements.
You must download and install MySQL Workbench 8.0.29 in advance. For more information, visit the MySQL Workbench download page.
Start MySQL Workbench and choose
.On the Connect to Database page, enter the information about the required connection address and the account.
Configure the Connection Method parameter. In this topic, Standard(TCP/IP) is used.
Configure the Hostname parameter. You must determine whether the RDS instance can be connected over an internal network based on your business requirements and specify the required endpoint. In this topic, an internal endpoint is used. For more information about how to determine whether an RDS instance can be connected over an internal network and how to obtain the internal or public endpoint, see Preparations.
Configure the Port parameter. In this topic, port
3306
is used.Configure the Username parameter. In this topic, the privileged account named
dbuser
is used.Configure the Password parameter. You must specify a custom password.
Click OK to connect to the RDS instance. Then, you can perform subsequent operations.
Common errors and solutions
FAQ
How do I use Function Compute to obtain data from my RDS instance?
You can install third-party dependencies for your functions in Function Compute and use built-in modules to obtain the data of your RDS instance. For more information, see Install third-party dependencies for a function.
References
What do I do if I am unable to connect to an ApsaraDB RDS instance?
For more information about how to connect to an RDS instance that runs a different database engine, see the following topics: