You can import data from a self-managed MySQL database or an ApsaraDB RDS for MySQL database into Simple Log Service. After the data is imported, you can query, analyze, and process it. This topic describes how to import data from a MySQL database.
The MySQL Data Import feature of Simple Log Service will no longer be updated or maintained. The end-of-life date and migration details will be announced later. Use DataWorks for data synchronization. For more information, see MySQL data source.
Limits
This feature is available in the following regions: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Chengdu), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Hong Kong), Singapore, Malaysia (Kuala Lumpur), Indonesia (Jakarta), Philippines (Manila), Thailand (Bangkok), Japan (Tokyo), South Korea (Seoul), UK (London), Germany (Frankfurt), US (Virginia), and US (Silicon Valley).
If the data source is AnalyticDB for MySQL, you must convert JSON fields to the
VARCHARtype before you import them. For example, if thedetailfield is of the JSON type, you can usecast(detail as VARCHAR) as detailto convert it. For more information about the CAST function, see CAST functions.
Prerequisites
A MySQL database is created. A database account is also created and granted the minimum read permissions.
The required IP address is added to the whitelist of the MySQL database.
Add the IP address to the whitelist based on the region of the project and the network type of the database. For more information about the IP addresses that you can add to a whitelist, see IP address whitelists. For more information about how to add an IP address to the whitelist of a MySQL database, see Configure an IP address whitelist.
A project and a Logstore are created. For more information, see Manage a project and Create a Logstore.
Import data
Log on to the Simple Log Service console.
In the Projects section, click the one you want.

On the tab, click > to the left of the destination Logstore, hover over , and click +.

In the Quick Data Import dialog box, search for and click MySQL-Data Import.
Set the import configuration.
On the Data Source Settings tab, configure the following parameters.
Advanced parameters
Click Preview to preview the import results. After you confirm that the results are correct, click Next Configuration.
On the Scheduling Interval tab, configure the following parameters.
Parameter
Description
Import Interval
The interval at which data is imported from the MySQL database to Simple Log Service.
Execute Immediately
Turn on Execute Immediately to run the import task once right away.
After you complete the configuration, click Next.
Create indexes and preview data. Then, click Next. By default, full-text indexing is enabled in Simple Log Service. You can also manually create field indexes for the collected logs or click Automatic Index Generation. Then, Simple Log Service generates field indexes. For more information, see Create indexes.
ImportantIf you want to query all fields in logs, we recommend that you use full-text indexes. If you want to query only specific fields, we recommend that you use field indexes. This helps reduce index traffic. If you want to analyze fields, you must create field indexes. You must include a SELECT statement in your query statement for analysis.
You must wait approximately 1 minute for the indexes to take effect. Then, you can view the collected logs on the Raw Logs tab. For more information about how to query and analyze logs, see Guide to log query and analysis.
View the import configuration and statistical reports
After an import configuration is created, you can view the configuration and its statistical reports in the console.
Click the destination project.
In the destination Logstore, choose and click the destination import configuration.

On the Import Configuration Overview page, view the basic information and statistical reports of the import configuration.
Related operations
On the Import Configuration Overview page, you can also perform the following operations.
Modify the configuration
Click Modify Configuration to modify the import configuration. For more information about the parameters, see Import data.
Delete the configuration
Click Delete Configuration to delete the import configuration.
WarningThis operation cannot be undone. Proceed with caution.