0% found this document useful (0 votes)
3 views6 pages

Export Data From a MySQL Database

MySQL Workbench allows users to export data from a MySQL database in various formats, including CSV, XML, and SQL INSERT statements. Users can export the result set of a query or the entire database, choosing to include structure, data, or both. The document outlines the steps for exporting query results and databases, including naming files and configuring export options.

Uploaded by

khadija akhtar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Export Data From a MySQL Database

MySQL Workbench allows users to export data from a MySQL database in various formats, including CSV, XML, and SQL INSERT statements. Users can export the result set of a query or the entire database, choosing to include structure, data, or both. The document outlines the steps for exporting query results and databases, including naming files and configuring export options.

Uploaded by

khadija akhtar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

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
After running a query, click on the Export icon above the result set.

1. Name the File

Enter a name for the file. Note that you can export to many different file
formats.
Click Save.

2. The Result
This will export your query result set and the data will be saved to the file that
you specified.
Now you can open that file in an external application or import it into a
different database.
Here's what the above CSV file looks like when I open it in OpenOffice.

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:

1. Start the Export


Ensure that the MANAGEMENT tab is selected on the left menu.
Click on the Data Export link.

2. Configure & Run the Export


The Data Export screen will appear. Select the database to export (as well as
which tables/objects to include). Choose whether to a self–contained file or
separate files.
In this case I chose Dump Structure and Data because I wanted the whole
database, including its tables and the data. If you only want to export the data,
change this to Dump Data Only. If you only want the database without the data,
select Dump Structure Only.
Also, I chose Export to Self–Contained File and then Create Dump in a
Single Transaction (self–contained file only), and Include Create
Schemaso that the script will create the database before trying to insert its
contents.
Once done, click Start Export

3. Enter Password

If prompted for password, enter it and click OK

4. The Result
The export operation will now be executed. Once completed, the Export
Progress screen reads Export Completed.

Next we'll open this file and run it to restore our whole database.

You might also like