To manage a pre-installed or self-installed database in a Simple Application Server instance, use Alibaba Cloud Data Management (DMS). This topic uses a MySQL database pre-installed in a WordPress application image as an example to show how to connect to the database by using DMS.
Prerequisites
You must have a Simple Application Server instance that uses a WordPress application image. For more information, see Quickly build a website by using a WordPress application image.
After you create the WordPress instance, add a firewall rule to allow traffic on port 3306, which is the listener port for MySQL. For more information, see Manage firewalls.
Background information
Data Management (DMS) is a data management service that integrates features such as data management, schema management, user authorization, security audit, data trending, and data tracking. For more information about the features of DMS, see What is Data Management (DMS)?
Step 1: View the database credentials
Some application images provided by Simple Application Server, such as WordPress, include a pre-installed MySQL database. Follow this step to view the credentials for this database. If you installed the database yourself, skip this step and use your own administrator password.
-
Go to the Servers page in the Simple Application Server console.
On the WordPress instance card, click the instance ID.
Click the Application Details tab. In the MariaDB 10.5.6 section, find Administrator Password and click Quick View.
In the Quick View dialog box, view the database username and password.
Step 2: Create a database user for DMS
Run the following command to log in to the MySQL database:
mysql -uroot -pAt the Enter password: prompt, enter the administrator password.
NoteFor data security purposes, no output is returned when you enter a password. You need only to enter the correct password and then press the Enter key.
On the MySQL command line, run the following command to create a user for the DMS connection:
This example creates a user named
dmsand sets the password toEcs123!.ImportantChoose a strong password and keep it secure.
create user 'dms'@'%' IDENTIFIED BY 'Ecs123!';Run the following command to grant the user remote connection permission for DMS:
To ensure data security, grant remote connection permission only to the IP addresses that DMS uses.
In this example, the WordPress instance is in the China (Hangzhou) region, and its Instance source in DMS is set to Internet. Therefore, you only need to allow connections from the DMS IP address range
101.37.74.0/24. For more information, see DMS IP address list.grant all privileges on *.* to 'dms'@'101.37.74.0/24' identified by 'Ecs123!' with grant option;Run the following command to apply the changes immediately:
flush privileges;Run the following command to exit MySQL:
\q
Step 3: Connect to the MySQL database
Log in to DMS 5.0.
-
In the Database Instances area on the left side of the console home page, click the Add Instance
icon.NoteAlternatively, on the top menu bar, choose and then click Add.
In the add instance dialog box, configure the following key parameters.
This step covers only the key parameters. You can use the default values for the others. For more information about the parameters, see Register a third-party cloud or self-managed database.
Category
Parameter
Description
Data source
-
Select third-party cloud/self-managed.
Basic information
Database type
Defaults to MySQL.
Instance source
Select Internet.
Instance region
Select the region where the Simple Application Server instance is deployed. In this example, China (Hangzhou) is selected.
Login address
Enter the public IP address of your WordPress instance.
Port
The default listener port for MySQL is 3306.
Database account
The database username. In this example, enter
dms.Database password
The password for the database user. In this example, enter
Ecs123!.Click test connection.
If the connection is successful, a confirmation message appears, as shown in the following figure.

Click OK. Then, in the lower-right corner of the add instance dialog box, click Submit.