A self-managed database is one that you install and configure on an Elastic Compute Service (ECS) instance. You can use Data Management Service (DMS) to centrally manage these databases, with capabilities including enterprise-wide data asset management, data governance, database design and development, data integration, data development, and data consumption. This topic uses MySQL as an example to demonstrate how to add and manage a self-managed database on an ECS instance by using DMS.
Prerequisites
-
You have activated Data Management Service. For more information, see DMS.
-
You have added an inbound rule to the security group of the ECS instance to allow traffic on port 3306, which is the default port for MySQL. For more information, see Add a security group rule.
-
You have installed a MySQL database on the ECS instance. For more information, see Deploy a MySQL database.
Procedure
-
(Optional) If your MySQL installation does not allow the root account to log on remotely, create a non-root account for the database.
We recommend that you use a non-root account to log on to the database. In this example, run the following commands to create a MySQL account named
dmsTestwith the passwordEcs@123****and grant all privileges to the account.-
Remotely log on to the ECS instance. For more information, see Log on to a Linux instance by using Workbench.
-
Run the following command and enter the password for the root user to log on to MySQL.
sudo mysql -uroot -p -
Run the following commands to create a MySQL account and grant it permissions for remote connections.
In this example, the account is
dmsTestand the password isEcs@123****.ImportantWhen you create the account, replace the sample password
Ecs@123****with a strong password that meets your requirements and store it securely. The password must be 8 to 30 characters long and contain uppercase letters, lowercase letters, digits, and special characters. The following special characters are supported:()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/# Create the dmsTest user and grant remote connection permissions. create user 'dmsTest'@'%' identified by 'Ecs@123****'; # Grant all privileges on all databases to the dmsTest user. grant all privileges on *.* to 'dmsTest'@'%'; # Flush privileges to apply the changes. flush privileges; -
Run the following command to exit the database.
exit
-
-
Use DMS to remotely access the MySQL database.
-
Log on to the DMS console.
-
In the top navigation bar, click Instances.
-
On the Instances tab, click Add.
-
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
Select MySQL.
Instance source
Select ECS-hosted self-managed instance.
Instance region
The region where the ECS instance is located. In this example, select China (Hangzhou).
ECS Instance ID
From the drop-down list, select the destination ECS instance.
Port
The port that the database on the ECS instance listens on. In this example, MySQL uses port 3306.
Access mode
In this example, select Security Hosting - Manual to enable security hosting. For more information, see Security hosting.
Database account
The account for the self-managed database on the ECS instance. In this example, the MySQL account is
dmsTest.NoteWe recommend that you use a non-root account.
Database password
The password for the database account. In this example, the password for the dmsTest account is
Ecs@123****. After configuring the parameters, click Test Connection in the lower-left corner.
NoteIf the connection test fails, check the instance information based on the error message.
-
After the Connection Succeeded message appears, click OK.
The database is now registered with DMS. You can view and manage your database in the instance list on the left side of the DMS console.
-