All Products
Search
Document Center

Simple Application Server:Connect DMS to a database on a simple application server

Last Updated:Jan 27, 2025

If you want to manage a preset or self-deployed 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 that is preset in the WordPress application image is used.

Prerequisites

  • A simple application server is created based on the WordPress application image. For more information, see Build a WordPress blog.

  • A rule is added to the firewall of the created WordPress server to allow traffic on MySQL listener port 3306. For information about how to add a firewall rule, see the Manage a firewall section of the "Manage the firewall of a simple application server" topic.

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 (For example, 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 that is preset in the WordPress simple application server. If your database is a self-deployed database, skip this step and proceed to Step 2 to log on to the database by using the password that you set for the database administrator.

  1. Log on to the Simple Application Server console.

  2. In the left-side navigation pane, click Servers.

  3. Click the server ID in the card of the WordPress server.

  4. Click the Application Details tab. In the MySQL Information section, click Quick View.

  5. In the Quick View message, obtain the username and password of the MySQL database.

Step 2: Configure a database user that you want to use to connect DMS to the MySQL database

  1. Run the following command to log on to the MySQL database:

    mysql -uroot -p
  2. At the Enter password: prompt, enter the password of the database administrator.

    Note

    For 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.

  3. On the MySQL command line, run the following command to create a user that you want to use to connect DMS to the MySQL database.

    In this example, a user named dms is created and the password of the user is set to Ecs123!.

    Important

    You must specify a username and password based on your business requirements and keep the password confidential.

    create user 'dms'@'%' IDENTIFIED BY 'Ecs123!';
  4. Run the following command to grant the user the permission to connect DMS to the MySQL database.

    To ensure data security, we recommend that you allow access only from the IP address of the DMS instance to the MySQL database.

    In this example, the WordPress server is deployed in the China (Hangzhou) region, and Internet is set as the data source when the MySQL database is added to DMS. In this case, you allow DMS instances to access the MySQL database only from the CIDR block 101.37.74.0/24 . For more information about DMS IP addresses and CIDR blocks, see the "DMS IP addresses and CIDR blocks" section of the Add DMS IP addresses and CIDR blocks to security settings topic.

    grant all privileges on *.* to 'dms'@'101.37.74.0/24' identified by 'Ecs123!' with grant option;
  5. Run the following command to make the configurations immediately take effect:

    flush privileges;
  6. Run the following command to exit MySQL:

    \q

Step 3: Connect DMS to the MySQL database

  1. Log on to the DMS console V5.0.
  2. On the Home page of the DMS console, click the add icon next to Database Instances in the left-side navigation pane.

    Note

    Alternatively, choose Data Assets > Instances in the top navigation bar. On the Instance List tab of the Instances page, click New.

  3. In the Add Instance dialog box, configure the parameters.

    The following table describes the key parameters. You can use the default values for other parameters. For more information about the parameters, see Register a database hosted on a third-party cloud service or a self-managed database.

    Section

    Parameter

    Description

    Data Source

    -

    The source of the database instance. In this example, select Third-party Cloud/Self-managed .

    Basic Information

    Database Type

    By default, MySQL is selected.

    Instance Source

    The database source. Select Internet.

    Instance Region

    Select the region where the simple application server is deployed. In this example, select the China (Hangzhou) region.

    Login Address

    Enter the public IP address of the simple application server. In this example, enter the public IP address of the WordPress server.

    Port

    3306 is automatically filled in. Port 3306 is the default listener port of MySQL.

    Database Account

    Enter the username that is used to connect DMS to the database. In this example, enter dms.

    Database Password

    Enter the password of the username that is used to connect DMS to the database. In this example, enter Ecs123!.

  4. Click Test Connection to test the connectivity of the database.

    The message shown in the following figure indicates that DMS is connected to the MySQL database on the WordPress server.dms连接成功

  5. Click OK. In the lower-right corner of the Add Instance dialog box, click Submit.

  6. In the Login confirmation message, click OK.

    After DMS is connected to the MySQL database on the WordPress server, you can view and manage the database on DMS.