How to Migrate Data From MySQL to InfluxDB

Updated

InfluxDB logo

There is no importer. You export rows from MySQL as line protocol — one line per point, with a measurement, a tag set, a field set and a nanosecond timestamp — and POST that to InfluxDB’s write endpoint. One SQL statement does the conversion:

SELECT CONCAT('sensor_readings,site=', site, ',sensor=', sensor,
              ' temperature_c=', temperature_c, ',humidity_pct=', humidity_pct,
              ' ', CAST(UNIX_TIMESTAMP(reading_at) * 1000000000 AS UNSIGNED))
FROM sensor_readings ORDER BY reading_at;

Run against 1,000 rows on MySQL 8.4.10, the first line out is:

sensor_readings,site=dallas,sensor=probe-2 temperature_c=28.25,humidity_pct=40.00 1786344531841000000
curl --data-binary @data.lp \
  -H "Authorization: Bearer $INFLUX_TOKEN" \
  "http://localhost:8181/api/v3/write_lp?db=sensors&precision=nanosecond"

What is verified here. The MySQL side above was executed and the output pasted unedited. InfluxDB is not installed on this machine, so no write response, no query result and no InfluxDB version banner appears on this page — the curl above is the documented endpoint, not a transcript. The companion script regenerates the export on a throwaway MySQL server that it starts and stops itself, re-checks the Telegraf flags and the InfluxData passages quoted below against their sources, and writes for real if you point INFLUX_URL at your own server. Everything about InfluxDB below is quoted from InfluxData’s own documentation, fetched on 2026-08-10.

Moving rows with Telegraf: inputs.sql, not a one-line command

This is not a working Telegraf command:

telegraf --input-filter mysql --output-filter influxdb_v2 --output=destination \
  --mysql-urls="root:password@tcp(localhost:3306)/dbname" \
  --tag-keys="column1,column2" --data-format=sql

Three of those flags are not Telegraf flags. Searching Telegraf’s own cmd/telegraf source in August 2026: --input-filter and --output-filter exist; --mysql-urls, --tag-keys and --data-format return no matches. And the two filter flags only select which plugins from a config file are enabled — they cannot carry a connection string.

The mysql input plugin is also the wrong one. Telegraf’s inputs.mysql README opens: “This plugin gathers statistics from MySQL server instances.” It collects SHOW GLOBAL STATUS counters, not the rows in your tables. The plugin that runs your own query is inputs.sql, whose README says it “reads metrics from performing SQL queries against a SQL server.” A working config looks like this — note it polls on an interval, so it suits ongoing replication rather than a one-shot backfill:

[[inputs.sql]]
  driver = "mysql"
  dsn = "user:password@tcp(127.0.0.1:3306)/appdb"

  [[inputs.sql.query]]
    query = "SELECT reading_at, site, sensor, temperature_c, humidity_pct FROM sensor_readings WHERE reading_at > ?"
    time_column = "reading_at"
    tag_columns_include = ["site", "sensor"]

[[outputs.influxdb_v3]]
  urls = ["http://127.0.0.1:8181"]
  token = "$INFLUX_TOKEN"
  database = "sensors"

The option is tag_columns_include (with a matching tag_columns_exclude); a plain tag_columns key does not exist in the plugin’s source.

Which InfluxDB, and which query language

This is where a 2023-era migration guide will send you wrong. Per docs.influxdata.com in August 2026, the current products are InfluxDB 3 Core 3.11 and 3 Enterprise 3.11, alongside the older InfluxDB OSS 2.9 and 1.12 lines. Version 3 is a ground-up rewrite, and the query languages moved with it:

  • InfluxDB 3 — SQL and InfluxQL. Not Flux.
  • InfluxDB 2.x — Flux and InfluxQL.
  • InfluxDB 1.x — InfluxQL (and Flux, later).

InfluxData’s own page on the subject is unambiguous: “Flux is in maintenance mode and is not supported in InfluxDB 3 due to the broad demand for native SQL and the continued growth and adoption of InfluxQL… If interested in transitioning to InfluxDB 3 and you want to future-proof your code, we suggest using InfluxQL.” If a tutorial hands you Flux dashboards or Flux tasks for a new project, it is targeting a version you probably should not be starting on.

The write path changed too. InfluxDB 3’s native endpoint is /api/v3/write_lp; it also still accepts /api/v2/write and the v1 /write for compatibility. The CLI is influxdb3 write --database ... --token .... By contrast, influx write -b "database_name" -o "org_name" is the v2 CLI: buckets and orgs are v2 concepts, and v3 Core/Enterprise use databases and tokens instead.

Design the schema before you export

Line protocol is measurement,tag=value field=value timestamp, and which column goes where is the whole migration. From InfluxData’s schema-design guide: “Use tags to store metadata, or identifying information… Use fields to store measured values. Tag values can only be strings,” and “In InfluxDB 3 Core, the primary key for a row is the combination of the point’s timestamp and tag set.”

That last sentence is the one that costs people data. Two rows sharing a timestamp and tag set are the same point — the second overwrites the first. A MySQL table with an auto-increment id and a per-second timestamp will collapse unless something in the tag set distinguishes the rows. Decide that before you export, not after.

Three more practical points, all from the current docs:

  • Precision. /api/v3/write_lp defaults to auto-detecting precision from the magnitude of the number, so a millisecond-epoch column can be read as milliseconds and a second-epoch column as seconds. Pass precision= explicitly. The SQL above multiplies to nanoseconds for exactly this reason.
  • Cardinality advice reversed in v3. The v2 docs warn that high series cardinality is “a primary driver of high memory usage”; the InfluxDB 3 schema-design page states the opposite for its own engine — that it “supports infinite tag value and series cardinality”. Old guidance about never tagging with an id is still right for 1.x/2.x and no longer applies to 3.x. There is still a column-count limit per table.
  • Vocabulary. A v2 bucket is a v3 database; a measurement is a table.

Do not migrate everything

InfluxDB’s own tradeoffs page is blunt about what you give up: “Updates to existing data are a rare occurrence and contentious updates never happen… Delete functionality is significantly restricted,” and duplicate points may be silently overwritten. Time-stamped append-only measurements belong in InfluxDB. Customers, orders, invoices — anything you update, join or delete by primary key — stay in MySQL. Most “migrations” that succeed are actually a copy of one or two metric tables, with MySQL still running underneath.

Photo of author
Sudhir P. founded HeatWare.com in 1999 and has built and operated it full-stack ever since; it is now used by more than 88,000 people. He writes here about the PostgreSQL, MySQL, Linux and DevOps work that keeps it running. Articles are rewritten only after the commands in them have actually been run, and the verification scripts are published alongside them so anyone can check the claims. Reach him at blog@heatware.net.