Export Data from a MySQL Database
MySQL Workbench provides an easy way to export data to an external source.
There are many ways to export data in MySQL. You can export a whole database. You can export one or more tables. You can also export the result set of a query.
Here, we use MySQL Workbench to perform the export operations.
Exporting the Result Set of a Query
Let's start by exporting the result set of a query.
You can export the result set of a query to a number of formats, including CSV, XML, HTML, JSON, SQL INSERT statements, Excel, and Tab separated.
You can export the result set of a query simply by running the query in MySQL Workbench, then clicking the Export icon where you're prompted to save the file. Steps below.
-
Start the Export
-
Name the File
-
The Result
Exporting the Database and/or its Contents
You can export the whole database, its tables, and/or their data to an SQL file. This file could be used later to restore the database and/or its contents.
You can choose whether to create one file for everything or one file for each table. Therefore, you could restore the whole database by running one file, or you could restore individual tables as required. You can also choose whether to export only the database structure, its data, or both.
Here are the steps involved in doing this:
-
Start the Export
-
Configure & Run the Export
-
Enter Password
-
The Result
Next we'll open this file and run it to restore our whole database.