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 perform operations on self-managed databases on ECS instances, including managing global data assets, designing and developing databases, and governing, integrating, developing, and consuming data. This topic describes how to use DMS to add and manage self-managed databases on an ECS instance. In this topic, a MySQL database is used.
Prerequisites
DMS is activated. For more information, go to the
DMS console.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 information about how to add an inbound security group rule, see Add a security group rule.
A MySQL database is installed on the ECS instance. For more information, see Deploy databases.
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 log on to MySQL. In this example, run the following commands to create an account named
dms
for MySQL, set the password of the account 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, an account named
dmsTest
is created and the password of the account is set toEcs@123****
.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 top navigation bar, click Instances.
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, MySQL is selected.
Basic Information
Database Type
The type of the database. Select MySQL.
Instance Source
The source type of the database instance. Select ECS-hosted self-managed instance.
Instance Region
The region where the ECS instance resides. In this example, China (Hangzhou) is selected.
ECSInstance ID
The ID of the ECS instance.
Port
The number of listening port for the database on the ECS instance. In this example, this parameter is set to 3306.
Security hosting
Specifies whether to enable security hosting. In this example, Enable is selected. For more information, see Security hosting.
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 the dms account is
Ecs123!
.After you configure the preceding parameters, click Test Connection in the lower-left corner.
NoteIf the connection test fails, check the specified instance information based on the error message.
If the connection test is passed, click Submit. Click Submit.
After you perform the preceding steps, the database is registered with DMS. You can view and manage your database instance in the left-side database instance list of the DMS console.