Skip to main content

MySQL

info

MySQL ingestion reads historical or continuous data through SQL time windows, either directly or through taosX-Agent. Pay particular attention to connection options: character set and SSL mode change query and session semantics. Do not disable production TLS or change global SQL modes to pass connectivity checks.

Entry point: taosExplorer → Data In → Create New Task → MySQL. Prepare the source in the MySQL client, and prepare and verify the target in taosExplorer's Data Browser or the taos CLI.

The actual reading host is taosX or the selected taosX-Agent host and needs permission to read the source table. An authorized TDengine TSDB administrator prepares the target.

1. Prerequisites and Test Objects​

Ask the source administrator for the host, port, database, and read-only account. Confirm that test table readings has columns ts, device, and temperature, with queryable records in a one-minute window. Replace the names below if they differ. Also confirm the time type and time zone of ts, the character set, and server TLS requirements.

PrerequisiteHow to confirm
Reading hostWhen using taosX-Agent, check connectivity to the source from its host; otherwise, check from the taosX host. Connectivity from the browser host is not a substitute.
Source object and identityObtain the actual port from the administrator; 3306 is common. The account must connect to the specified database, SELECT from the test table, and execute the device DISTINCT query.
TLS materialPrepare a CA according to source policy, and a client certificate and private key if required. The identity running the actual reading service must be able to read these files.
Target and windowObtain target write permissions from the administrator. Record source column types, the committed test range, and representative values in the same window.

1.1 Optional Source Sample​

Skip this step if a test table with known data already exists. For a separate exercise, ask the MySQL administrator to run the following SQL in an approved test database. If a table with the same name exists, use another name; do not overwrite it.

CREATE TABLE taosx_mysql_readings (
ts DATETIME(3) NOT NULL,
device VARCHAR(32) NOT NULL,
temperature DOUBLE
);
INSERT INTO taosx_mysql_readings VALUES
('2026-11-20 00:00:00.000', 'd001', 23.5),
('2026-11-20 00:00:30.000', 'd001', 24.5),
('2026-11-20 00:01:00.000', 'd001', 25.5);
SELECT ts, device, temperature FROM taosx_mysql_readings
WHERE ts >= '2026-11-20 00:00:00' AND ts < '2026-11-20 00:01:00'
ORDER BY ts;

Expect two rows, with temperatures 23.5 and 24.5 in order. The 25.5 at the end boundary is outside the window. This example treats these dates without time zones as UTC; use the same convention for task time selection and mapping. If an existing source table uses another time zone, ask the source administrator to confirm the conversion first. If the dates fall outside target retention, adjust the source samples, task window, and verification conditions together. The source table below is taosx_mysql_readings; when using an existing table, replace its name consistently in configuration and queries.

1.2 Prepare the Target Schema​

An authorized TDengine TSDB administrator creates separate target objects in taosExplorer's Data Browser or the taos CLI. Use different names if objects with these names already exist:

CREATE DATABASE mysql_demo PRECISION 'ms';
CREATE STABLE mysql_demo.temperatures (ts TIMESTAMP, temperature DOUBLE)
TAGS (device VARCHAR(32));

2. Configure and Start​

2.1 Create a Task and Enter Basic Information​

Log in to taosExplorer for the target cluster, open Data In, and click Create New Task. Enter quickstart_mysql as the task name, select MySQL for Data Source Type, and select mysql_demo for Target Database.

MySQL task name, type, agent, and target database

For direct reads, leave the agent unselected. For proxy reads, select an online taosX-Agent that can access the source MySQL instance. If a new agent is needed, complete Agent Deployment and Maintenance first. Do not assume an unconfigured agent can already read the source. If the target database is missing from the list, check the connected cluster, whether the database exists, and account permissions.

2.2 Enter Connection and Authentication Details​

Under Connection Configuration, enter the MySQL Server Address, Server Port, and Database. This database is the MySQL database containing the source table, not target mysql_demo, unless the source database actually has that name. The address must be accessible from the actual reading host. The displayed 127.0.0.1 applies only when source MySQL and the reading process are in the same runtime environment.

MySQL source address, port, and database

Under Authentication, enter the authorized source MySQL User and Password. This account is independent of the TDengine account used to log in to taosExplorer. It must at least query the test table; device grouping also requires permission to execute the corresponding DISTINCT query.

MySQL source username and password

Under Connection Options, check the character set, SQL modes, and SSL mode, then click Check Connectivity. If the connection fails, retain the returned error and diagnose it using section 5. Do not disable production TLS or change global SQL modes to pass the check. Section 3 explains the fields.

MySQL character set, SQL mode switches, and SSL mode

2.3 Set SQL and the Time Window​

Under SQL Query, leave Subtable Fields empty for the first exercise. Enter this SQL Template:

SELECT ts, device, temperature FROM taosx_mysql_readings
WHERE ts >= ${start} AND ts < ${end} ORDER BY ts;

Set the page time zone to UTC before filling in the task, to avoid resetting an unsaved form when changing time zones. Set Start Time to 2026-11-20 00:00:00 and End Time to 2026-11-20 00:01:00. In this UI version, Query Interval offers only days and hours. Select 1 hour for this example; the explicit end time limits this read to that one minute. Do not leave the end time empty on the first run. An empty end time enables continuous reads, not automatic detection of the end of historical data.

MySQL one-minute UTC window and one-hour query interval

The SQL template is a single-line input. The following image shows the end of the same input scrolled to the right; the complete statement is in the code above:

MySQL time boundaries and ordering at the end of the same SQL template

When there are many devices and they need separate reads, set Subtable Fields to SELECT DISTINCT device FROM taosx_mysql_readings; and add AND ${device} after the SQL template's time conditions. This placeholder expands to a complete equality condition; do not write device=${device}. For multi-field grouping, date placeholders, and late data handling, see Common Relational Database Rules.

2.4 Retrieve Samples and Configure Mapping​

  1. Expand Data Mapping and click Retrieve from Server. The initial sample limit is 5 rows and the request timeout is 30 seconds. These control only the sample request; they do not mean the production task has run or the window is complete.
  2. Under Recognized Columns, confirm ts, device, and temperature, and check time values, numeric types, and nulls. If no sample is returned, query the same window in the MySQL client first. Do not use fabricated samples to hide a failed source query.
  3. This example adds no extraction, splitting, or filtering. When needed, add rules using Relational Database Sample Mapping, and preview both matching and nonmatching samples separately.
  4. Under Mapping, select target supertable temperatures and child table template t_{device}. Map source ts to the target timestamp column, temperature to the DOUBLE data column, and device to the tag.
  5. Click Preview. It should generate t_d001, with times matching the source sample convention, temperatures 23.5 and 24.5, and device tag d001. If times are unexpected, check the source type, page time zone, and time conversion first. Do not replace source time with the current time.

MySQL sample retrieval, recognized columns, extraction, filtering, and mapping entry points

The image shows the configuration area before it is filled in. Select the target database and retrieve samples before completing mapping. For the complete extraction, filtering, and mapping syntax, see Extraction, Splitting, Filtering, and Transformation and Target Table Modeling and Field Mapping.

View configured mapping and results

The separate example below maps various source columns to supertable mysql_tb_test3, with child table tb_1. From top to bottom, the left side shows sample retrieval, recognized columns, extraction or splitting, filtering, and target mapping. The right side shows the mapping preview. This illustrates how to compare columns and values after configuration; it is not the result of the preceding three-column temperature sample. There is no need to create another multi-column test table for it.

MySQL multi-column mapping configuration and corresponding result preview

After clicking Preview in the actual task, compare the child table name, times, source columns, and target columns individually. Scroll horizontally to view columns beyond the panel. Do not check signed and unsigned integers, floating-point values, and nulls using only the first few columns. Back in the temperature exercise, expect t_d001 and the two known temperature records. Do not copy table names, column names, or values from the image. After a successful preview, still submit the task and query the target.

2.5 Submit and Confirm Task Status​

Check advanced options and error policies using section 3, then click Submit and find quickstart_mysql in the task list. Confirm that it has started. If not, start the original task rather than creating a duplicate. Check the status and activity description, retaining specific errors. Even when the list shows running or completed, verify target ingestion using section 4.

3. Connection Options to Confirm​

UI itemHow to configure
Server address, port, databaseEnter the actual MySQL service. A database name is neither a host nor a schema query condition.
User, passwordUse an authorized source identity, separate from the TDengine write identity.
Character setOptions are utf8, utf8mb4, utf16, utf32, gbk, big5, latin1, and ascii. Match source connection requirements. The UI initial value is utf8; a direct DSN without configuration uses utf8mb4. Do not conflate defaults from these two entry points.
Double-pipe string concatenationControls whether PIPES_AS_CONCAT is requested, affecting || semantics. Initially enabled in the UI.
No storage engine substitutionControls whether NO_ENGINE_SUBSTITUTION is requested. Initially enabled in the UI.
SSL modeThe UI offers DISABLED, PREFERRED, and REQUIRED: disabled, prefer TLS with fallback allowed, and require TLS. The initial value is PREFERRED. Encryption does not imply server identity verification.

The direct source DSN's ssl_mode also supports VERIFY_CA and VERIFY_IDENTITY. The former verifies the server certificate trust chain; the latter additionally verifies server identity. Neither appears in the UI dropdown above. For strict verification or client certificates, confirm the configuration entry point and required material with the delivery team first; do not search for nonexistent UI options. ssl_ca applies to these two verification modes; ssl_client_cert and ssl_client_key supply the client certificate under VERIFY_IDENTITY. Paths are on the actual reading host, and the runtime identity must be able to read them. Do not enter private-key contents where a path is expected, or assume these parameters take effect when added to PREFERRED or REQUIRED.

Double-pipe string concatenation affects ||, and No storage engine substitution affects session SQL modes. Disabling an option does not remove modes already present in the server session. For other products compatible with the MySQL protocol, protocol compatibility does not mean these modes are supported. For example, check both options separately for Doris rather than reusing MySQL defaults.

For Doris, confirm the protocol and supported versions with the source administrator, disable both SQL mode options above, and verify a small scope. Disabling them only avoids actively requesting added modes; source-side checks are still required. Do not change the production service's global SQL modes for this purpose.

Task time_zone also sets the MySQL session time zone: TIMESTAMP comparisons use absolute instants, while DATETIME comparisons use wall-clock time in the task time zone. Both datetime placeholder pairs generate the same STR_TO_DATE expression to second precision; do not add quotes. For the task time zone source, MySQL version-specific offset ranges, and read-value handling, see Time and Time Zone. Query Interval only divides windows. For approximately once-per-second checks, the delay watermark, and minimum real-time windows, see Query Interval and Delay.

For direct source DSN configuration, check types, defaults, units, and URL encoding in MySQL Read Parameters. Do not treat UI labels as parameter names.

The MySQL UI initially sets Query Interval to 1 day and Delay to 0 seconds. This example changes the interval to 1 hour and uses explicit start and end times to limit the exercise to one minute. Minimum Real-Time Sync Window initially is 10 seconds. It controls windows in the continuous phase, not the sleep duration of each task; it is not Oracle scheduling. The initial sample limit is 5 rows and the request timeout is 30 seconds. Retrieving samples does not mean the entire query window is synchronized.

3.1 Advanced Options​

Expand Advanced Options. Maximum Read Concurrency controls simultaneous source reads, while Batch Size controls batches passed to the downstream write pipeline. Neither is the query time window. Establish a baseline using one device and one bounded window, then adjust one setting at a time based on source load, task duration, and target writes. Do not begin a whole-database migration at maximum settings.

MySQL advanced options and initial UI values

The new-task form initially sets maximum read concurrency to 0 and batch size to 10000. Also record the health-check window, write queue, and error threshold. The threshold is not an allowable number of lost rows. For direct DSN defaults, zero values, and scope, see Advanced Query Source Parameters; initial form values are not direct DSN defaults. See Tuning and Resource Control for tuning, and Health Checks and No-Data Diagnosis for health fields.

3.2 Write Error Policy​

warning

After previewing mappings and before submitting the task, expand Error Handling Policy. The administrator has already created this example's target supertable. Allowing automatic child table creation does not authorize arbitrary column expansion. Check null time columns, numeric conversion, and overlong device identifiers carefully. Archiving or discarding can leave fewer target rows than source rows. Advancing read windows alone does not prove a complete migration.

For archive queries and file extraction, see Logs and Performance. For affected scope and backfill, see Write Errors and Invalid Data.

4. Verification​

Record one source device and time window, then query the actual child table in taosExplorer's Data Browser or the taos CLI. For example, device d001 corresponds to:

SELECT ts, temperature, device FROM mysql_demo.t_d001
ORDER BY ts LIMIT 20;

The first exercise with a separate empty target should return two rows, with temperatures 23.5 and 24.5 in order, both for device d001, excluding 25.5 at the end boundary. Compare times, values, and devices individually against the same source window. Preview itself does not write to the target. If the target already contains records, filter by this window and account for overwrites with the same primary key. Do not substitute cumulative whole-database counts for this migration's count. After the trial migration, configure continuous mode as needed and verify newly committed data.

4.1 Separate Exact Decimal and Date Example​

This example is separate from the temperature exercise and uses approved, dedicated MySQL and TDengine test databases. It verifies decimals, dates, microsecond times, and nulls without changing the temperature task.

In the MySQL client, first confirm that the current database is the dedicated test database, then create the source table and insert three rows:

SET time_zone = '+00:00';
CREATE TABLE exact_readings (
event_time DATETIME(6) NOT NULL,
device VARCHAR(32) NOT NULL,
amount DECIMAL(38,10),
business_day DATE,
elapsed TIME(6)
);
INSERT INTO exact_readings VALUES
('2026-11-20 00:00:00.123456','d001',12345678901234567890.1234567890,'2026-11-20','12:34:56.123456'),
('2026-11-20 00:00:00.223456','d001',-0.0000000001,'2026-11-20','25:00:00.000001'),
('2026-11-20 00:00:00.323456','d001',NULL,NULL,NULL);
SELECT event_time, device, CAST(amount AS CHAR) AS amount_text,
CAST(business_day AS CHAR) AS business_day_text,
CAST(elapsed AS CHAR) AS elapsed_text
FROM exact_readings
WHERE event_time >= '2026-11-20 00:00:00'
AND event_time < '2026-11-20 00:01:00'
ORDER BY event_time;

Retain the source results above. amount_text should retain all significant digits; the three nullable fields in the third row are genuine NULL. MySQL TIME can also represent durations longer than one day or negative durations. Preserve this example's 25:00:00.000001 as text; do not convert it to a primary timestamp as if it were a clock time on a particular date.

Create a separate target with microsecond precision in taosExplorer's Data Browser or the taos CLI:

CREATE DATABASE mysql_exact_demo PRECISION 'us';
CREATE STABLE mysql_exact_demo.exact_readings
(ts TIMESTAMP, amount DECIMAL(38,10), business_day_text NCHAR(10), elapsed_text NCHAR(24))
TAGS (device VARCHAR(32));

Create a separate MySQL task using the source test database above and this page's connection steps. Select target database mysql_exact_demo and explicitly set the UTC window from 2026-11-20 00:00:00 to 00:01:00. Source DATETIME has no time zone; this example assumes it stores UTC. If the business convention differs, adjust the task's time interpretation accordingly. Use this SQL template:

SELECT event_time, device, CAST(amount AS CHAR) AS amount_text,
CAST(business_day AS CHAR) AS business_day_text,
CAST(elapsed AS CHAR) AS elapsed_text
FROM exact_readings
WHERE event_time >= ${start} AND event_time < ${end}
ORDER BY event_time;

Include all three rows when retrieving samples, retain the amount_text string, then select the target supertable and configure:

TargetSource and settingRequired checks
Child tablet_{device}All three rows enter t_d001.
tsevent_time, converted to a timestamp using the source datetime format and UTCRetain six fractional digits; do not merge the three rows into one millisecond primary key.
amountamount_text, target DECIMAL(38,10)Convert directly to decimal fixed-point, without first converting to DOUBLE; do not set a default zero.
business_day_textSame-named source field, NCHAR(10)Preserve the original date text; nulls must not become the string "NULL".
elapsed_textSame-named source field, NCHAR(24)Preserve durations longer than a day and microseconds.
Tag devicedeviceAll three rows are d001.

Preview the three rows and target types, then submit and start the task. Run the following in taosExplorer's Data Browser or the taos CLI:

DESCRIBE mysql_exact_demo.exact_readings;
SELECT ts, amount, business_day_text, elapsed_text, device
FROM mysql_exact_demo.t_d001
ORDER BY ts;
SELECT COUNT(*) AS total_rows, COUNT(amount) AS nonnull_amount_rows
FROM mysql_exact_demo.t_d001;

Expect 3 total rows and 2 non-null amounts. Amounts in the first and second rows must exactly equal 12345678901234567890.1234567890 and -0.0000000001; the third remains null. Timestamp fractions are .123456, .223456, and .323456 in order. If the client displays scientific notation or limits displayed digits, retain raw query results that have not been parsed as floating-point before comparing. Do not pass verification based on displayed approximations.

In a separate isolated preview, also test inputs exceeding target precision, excessive fractional digits, and invalid characters. Check actual errors and the selected error actions; these inputs are not part of the three normal samples above. If existing target columns differ from the task's specified types, resolve the model mismatch first rather than relying on automatic column expansion or rerun overwrites. For read representations and date differences in other relational databases, see Fixed-Point and Date Rules.

5. Troubleshooting​

SymptomChecks
Connection initialization failsCheck account, character set, SSL, and session SQL modes, especially for protocol-compatible products.
No data in the query windowQuery the source client using the same time and time zone. Confirm data is committed and the template expands correctly.
Garbled Chinese text or incorrect target typesCheck the source connection character set, actual sample types, and target column definitions.
Fewer target rows than source rowsCheck windows and time zones first, then filtering, primary-key collisions for the same device and time, archiving, and discarding. Increasing concurrency is not a solution.

For other task, write, and runtime issues, see Troubleshooting by Symptom.

6. Stop, Resume, and Limitations​

Stop the original task and retain its state. After resuming, check unfinished windows. This query path does not guarantee capture of changes to old data that the cursor has already passed, and it does not automatically migrate MySQL indexes, triggers, or user permissions. Verify original business queries separately before switching data sources.