If you want to manage a preset or self-managed database on a simple application server,
we recommend that you use Alibaba Cloud Data Management (DMS). This topic describes
how to use DMS to connect to a database on a simple application server. In this example,
a MySQL database preset in the WordPress application image is used.
Prerequisites
- A simple application server is created from the WordPress application image. For more
information, see Use an application image to create a server.
- A rule is added to the firewall of the created WordPress server to allow traffic on
the MySQL listener port, which is port 3306. For more information, see Add a firewall rule.
Background information
DMS provides an integrated solution that supports data management, schema management,
user authorization, security audit, trend analysis, and data tracking. For more information
about DMS, see What is DMS?.
Step 1: View the logon information of the MySQL database
MySQL databases are preset in specific application images such as the WordPress application
image that are provided by Simple Application Server. You can perform this step to
view the logon information of the MySQL database preset in the WordPress application
image. If the MySQL database is a self-managed database, skip this step and proceed
to Step 2 to log on to the database with the password that you set for the database
administrator.
- Log on to the Simple Application Server console.
- In the left-side navigation pane, click Servers.
- Find the WordPress server and click the server card.
- In the left-side navigation pane, choose .
- In the MySQL Information section, click Copy and then click Connect.
- In the command line window of the server that appears, right-click anywhere and select
Paste to paste the copied command, and then press the Enter key. View the password
of the database administrator in the command output.
- Select and right-click the password of the database administrator. For subsequent
logons, select Copy to copy the password and then paste it to your computer.
Keep the password confidential.
Step 2: Configure a database user to be used to connect to DMS
- On the server command line, run the following command to switch to the
root
user:
- Run the following command to log on to the MySQL database:
/usr/local/mysql/bin/mysql -uroot -p
- At the Enter password: prompt, enter the password of the database administrator.
Note When you enter a password, no command output is returned to maximize data security.
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 to be used to
connect to DMS.
In this example, a user named
dms
is created and the password of the user is set to
Ecs123!
.
Notice You must specify the username and the password based on your needs and keep the password
confidential.
create user 'dms'@'%' IDENTIFIED BY 'Ecs123!';
- Run the following command to grant the user the permission to connect to the MySQL
database from DMS.
To ensure data security, we recommend that you allow access only from the DMS IP address
to the MySQL database.
In this example, the WordPress server is deployed in the China (Hangzhou) region,
and Public Network is set as the data source when the MySQL database is added to DMS.
In this case, you can allow access only from the DMS IP address 101.37.74.0/24
for the China (Hangzhou) region to the database. For more information, see Configure an IP address whitelist.
grant all privileges on *.* to 'dms'@'101.37.74.0/24' with grant option;
- Run the following command to make the configurations immediately take effect:
- Run the following command to exit MySQL:
Step 3: Use DMS to connect to the MySQL database
- Log on to the DMS console.
- In the upper-left corner, move the pointer over and select Create Instance.
- In the Create Instance dialog box, click Public Network and then click MySQL.
- In the Basic Information section, configure the following parameters:
- Instance Region: Select the region where the simple application server is deployed.
In this example, the China (Hangzhou) region is used.
- Login Address: Enter the public IP address of the simple application server. In this
example, the public IP address of the WordPress server is used.
- Port: Enter 3306. Port 3306 is the default MySQL listener port.
- Database Account: Enter a username used to connect to the database from DMS. In this
example, the
dms
username is used.
- Database password: Enter the password of the user used to connect to the database
from DMS. In this example,
Ecs123!
is used.
- Control Mode: Select Flexible Management. For more information, see Control modes.
In this example, the parameters in the
Advanced Information section are skipped. You can configure these parameters based on your business needs.
For more information, see
Register an ApsaraDB instance.
- Click Test Connection to test the connectivity of the database.
The message shown in the following figure indicates that you can connect to the MySQL
database on the WordPress server by using DMS.

- Click OK. In the lower-right corner of the Create Instance dialog box, click Submit.
- In the Login confirmation message, click OK.
When you are connected to the MySQL database on the WordPress server from DMS, a page
similar to the following one appears. You can view and manage the database.
