Self-managed databases on Elastic Compute Service (ECS) instances are databases that are installed and configured on ECS instances. You can use Data Management (DMS) to manage self-managed databases on ECS instances. This topic describes how to use DMS to add and manage self-managed databases on ECS instances. In this topic, a MySQL database is used as an example.
Prerequisites
DMS is activated. For more information, see DMS.
An ECS instance of a memory-optimized r-series instance family is created. For information about how to create an ECS instance, see Create an instance on the Custom Launch tab.
An inbound rule is added to a security group of the ECS instance to allow traffic on port 3306, which is the default port that MySQL listens on. For more information, see Add a security group rule.
A MySQL database is installed on the ECS instance. For more information, see Deploy databases.
Background information
DMS is a database management web terminal provided by Alibaba Cloud to help manage self-managed databases on ECS instances that run Windows or Linux. You can add self-managed databases in the DMS console to use data management features such as database and table creation. DMS supports self-managed MySQL, SQL Server, PostgreSQL, MongoDB, and Redis databases. For more information, see DMS documentation.
Procedure
(Optional) If MySQL does not allow remote access from the root account, create a non-root account to connect to MySQL.
We recommend that you use a non-root account to connect to MySQL. In this example, run the following commands to create an account named
dms
for MySQL, set the password toEcs123!
, and then grant all permissions to the account.Connect to the ECS instance. For more information, see Connect to a Linux instance by using a password or key.
Run the following command and enter the password of the root account to log on to MySQL:
sudo mysql -uroot -p
Run the following commands in sequence to create an account and allow remote access to MySQL by using the account.
In this example, the
dmsTest
account and theEcs@123****
password are used.ImportantWhen you create an account, replace the
Ecs@123****
password with a valid password and keep the password confidential. The password must be 8 to 30 characters in length and must contain uppercase letters, lowercase letters, digits, and special characters. The following special characters are supported:( ) ` ~ ! @ # $ % ^ & * - + = | { } [ ] : ; ' < > , . ? /
# Create an account named dmsTest and grant the remote connection permissions to the account. create user 'dmsTest'@'%' identified by 'Ecs@123****'; # Grant all permissions on MySQL to the dmsTest account. grant all privileges on *.* to 'dmsTest'@'%'; # Refresh the permissions. flush privileges;
Run the following command to exit MySQL:
exit
Use DMS to remotely access MySQL.
Log on to the DMS console.
In the left-side navigation pane, choose .
On the Instance List tab, click New.
In the Add Instance dialog box, configure the parameters for the self-managed database.
The following table describes the parameters. For more information, see Register a database hosted on a third-party cloud service or a self-managed database.
Parameter
Description
Data Source
Select Third-party Cloud/Self-managed.
Relational Database
The type of the self-managed database on the ECS instance. In this example, select MySQL.
Basic Information
Database Type
The type of the database. Select MySQL.
Network Type
The access method of the database. Select ECS-hosted self-managed instance.
Instance Region
The region where the ECS instance resides. In this example, select China (Hangzhou).
ECSInstance ID
The ID of the ECS instance.
Port
The listening port number for the database on the ECS instance. In this example, set Port to 3306.
Database Account
The account used to log on to the self-managed database on the ECS instance. In this example, the account used to log on to MySQL is
dms
.NoteWe recommend that you use a non-root account.
Database Password
The password used to log on to the self-managed database on the ECS instance. In this example, the password of dms is
Ecs123!
.Control Mode
The control mode of the instance. In this example, select Flexible Management. For more information about the control modes, see Control modes.
Click Submit.
Log on to the database.
If you are prompted to add the IP addresses and CIDR blocks of DMS to the whitelist of the database, configure the IP address and CIDR blocks as prompted and log on to the database again. For information about how to add IP addresses and CIDR blocks of DMS to the IP address whitelist of a database, see Configure an IP address whitelist.
What to do next
After you log on to the database, you can perform operations on the database in the DMS console or by using SQL statements.