You can use MySQL Workbench to run a query, then export the results of that query to a file.
To do this:
- Run the query
- Click Export on the Results Grid menu bar
Here’s a screenshot:
Important: MySQL Workbench limits the result set to 1000 rows by default. Be sure to remove this limitation if you don’t want your result set to be limited to that amount (or some other amount if it has been specified).
You can change that setting by clicking the Limit to 1000 rows dropdown and selecting Don't Limit.
File Formats
You have a choice of file formats to save the file in. Here are the formats supported at the time of writing:
- CSV
- CSV (; separated)
- HTML
- JSON
- SQL INSERT statements
- Excel Spreadsheet
- XML
- XML (MySQL format)
- Tab separated
The Query Menu
You can also initiate the export via the MySQL Workbench Query menu:
You can also use the SELECT ... INTO OUTFILE
statement to export the query results from within the query. This exports the file as soon as the query runs.