Get subscription relationship from MySQL

    Initialize the MySQL database:

    Create the mqtt_sub table:

    TIP

    The subscription relationship table structure cannot be modified. Please use the above SQL statement to create

    Create rules:

    Open EMQX Dashboard (opens new window) and select the “Rules” tab on the left.

    Then fill in the rule SQL:

    Get subscription from MySQL - 图2

    Related actions:

    Fill in the action parameters:

    The action of “Get subscription list from MySQL” requires one parameter:

    1). Associated resources. The resource drop-down box is empty now, and you can click “New” in the upper right corner to create a MySQL resource:

    Get subscription from MySQL - 图4

    The “Create Resource” dialog box pops up

    Fill in the resource configuration:

    Fill in the real MySQL server address and the values corresponding to other configurations, and then click the “Test Connection” button to ensure that the connection test is successful.

    Get subscription from MySQL - 图6

    Return to the response action interface and click “OK”.

    Return to the rule creation interface and click “Create”.

    Get subscription from MySQL - 图8

    The rule has been created, and you can insert a subscription relationship into MySQL through “mysql”:

    Log in to the device whose clientid is test via Dashboard:

    Get subscription from MySQL - 图10