MySQL to Excel: Export Query Results as .xlsx
Last updated August 29, 2026 · By the SaturnSQL team
Getting MySQL rows into Excel is easy. Getting them there without stripped leading zeros, bigint IDs collapsing into scientific notation, or a silently truncated result set is where the methods differ. This guide covers the four routes for MySQL and MariaDB, and when each one is the right call.
The short version
If the data has leading zeros, long IDs, or dates in it, export a genuine .xlsx workbook rather than a CSV, so the cell types are written into the file instead of guessed by Excel. If the same export happens every week, put the query on a schedule instead and stop doing it by hand. The general tradeoffs across all engines are in the export SQL to Excel guide.
Method 1: a one-click .xlsx download
SaturnSQL is a browser-based SQL editor. Connect MySQL or MariaDB with a read-only user, run the query, open the export menu above the results grid, and pick XLSX. The file is a real workbook with a header row: numbers stay numbers, dates stay dates, and Excel opens it without an import dialog or a type-conversion warning.
On MySQL the export streams, so there is no row cap; the only bound is the query timeout. That matters because most grid-based clients export only the rows the grid fetched, which is rarely the whole result.
Method 2: the mysql command line
Scriptable and size-indifferent, but the output is delimited text rather than .xlsx. Batch mode writes tab-separated values, which Excel opens cleanly enough for simple data:
mysql -h db.example.com -u report -p \
-e "SELECT id, name, created_at FROM customers" \
mydb > customers.tsvThe SELECT ... INTO OUTFILE form produces cleaner CSV but writes on the database server, requires the FILE privilege with a path inside secure_file_priv, and is therefore usually unavailable on managed hosts like RDS, Aurora, and PlanetScale. Either way, Excel type-guesses every column when it opens the file, so read the paste-and-CSV warnings in the general guide before trusting the result.
Method 3: MySQL Workbench’s grid export
In Workbench, run the query and use Export recordset to an external file from the result grid. CSV is the dependable format choice across versions. Fine for a small one-off, with one trap worth knowing:
Workbench appends LIMIT 1000 by default. The Limit Rows setting in the SQL editor toolbar quietly caps every query, and the grid export writes only what the grid holds. If the weekly report has exactly 1,000 rows in it, this is why. Turn the limit off before exporting.
Method 4: stop exporting, schedule it
Most people who export a MySQL query to Excel once end up exporting the same query every week. The manual loop, run, export, open, delete last week’s rows, paste, fix the date column, is exactly what scheduling removes. In SaturnSQL you save the query, attach a schedule with a cron cadence and an IANA timezone, and each run writes the fresh rows to the destination. Hourly refresh is included in the €19/mo base plan.
Where scheduled runs deliver
Scheduled runs deliver to a Google Sheet or to Slack. SaturnSQL does not email an .xlsx attachment on a timer. For Excel users a Sheet is one click away (File → Download → Microsoft Excel (.xlsx)), and unlike a mailed file the URL stays stable, so pivot tables and formulas pointing at it keep working run after run. The full setup is in the MySQL to Google Sheets guide.
Frequently asked questions
How do I export MySQL query results to Excel?
Use a client that writes a genuine .xlsx. In SaturnSQL, run the query and pick XLSX from the export menu; the export streams with no row cap on MySQL. The mysql CLI and INTO OUTFILE produce CSV instead, which lets Excel guess every column’s type on open.
How do I export MySQL to Excel automatically?
Put the saved query on a schedule. SaturnSQL runs it on a cron cadence and writes the rows to a Google Sheet or Slack; the Sheet is one click from an .xlsx download and the link stays stable. Scheduled delivery is to Sheets or Slack, not an emailed attachment.
Why is my Workbench export missing rows?
Workbench appends LIMIT 1000 by default via the Limit Rows toolbar setting, and the grid export writes what the grid holds. Turn the limit off or raise it before exporting.
How many rows can I export?
Excel stops at 1,048,576 rows per worksheet. SaturnSQL streams MySQL exports with no cap of its own, bounded only by the query timeout. Grid-based clients usually export only what the grid fetched.
Export a real .xlsx from MySQL in one click, or put the query on a schedule and stop exporting it at all.