How do i export only data from mysql workbench?

Back to: MySQL Tutorials for Beginners and Professionals

In this article, I am going to discuss how to Export and Import MySQL Database using MySQL Workbench. Please read our previous article, where we discussed how to Insert, Update and Delete Data Rows using MySQL Workbench.

Export MySQL database using MySQL Workbench:

In order to export a database using MySQL Workbench, we should have a database on our MySQL Server. So, let us first create a Database called School and tables Students and StudentAddress with some data. Please use the below SQL Script to create the database, table, and data.

CREATE DATABASE School;
USE School;

CREATE TABLE `School`.`Students`(
  StudentId INT PRIMARY KEY,
  FirstName VARCHAR(50),
  LastName VARCHAR(50),
  Class VARCHAR(50),
  Age INT
);

INSERT INTO `school`.`students` (StudentId, FirstName, LastName, Class, Age) 
VALUES (1, 'Anurag', 'Mohanty', 'First', 18);
INSERT INTO `school`.`students` (StudentId, FirstName, LastName, Class, Age) 
VALUES (2, 'Priyanka', 'Dewangan', 'Second', 17);
INSERT INTO `school`.`students` (StudentId, FirstName, LastName, Class, Age) 
VALUES (3, 'Hina', 'Sharma', 'First', 19);
INSERT INTO `school`.`students` (StudentId, FirstName, LastName, Class, Age) 
VALUES (4, 'Sambit', 'Monanty', 'Second', 17);

CREATE TABLE `school`.`studentaddress` (
  AddressId INT PRIMARY KEY,
  StudentId INT NOT NULL,
  City VARCHAR(200),
  State VARCHAR(200)
);

INSERT INTO `school`.`studentaddress` (AddressId, StudentId, City, State) 
VALUES (1, 1, 'BBSR', 'Odisha');
INSERT INTO `school`.`studentaddress` (AddressId, StudentId, City, State)
VALUES (2, 2, 'Mumbai', 'Maharashtra');
INSERT INTO `school`.`studentaddress` (AddressId, StudentId, City, State) 
VALUES (3, 3, 'BBSR', 'Odisha');
INSERT INTO `school`.`studentaddress` (AddressId, StudentId, City, State)
VALUES (4, 4, 'Mumbai', 'Maharashtra');

Now let us see how to export the School database. To do so, from the top menu select ‘Server’ and ‘Data Export’ Option as shown in the below image.

How do i export only data from mysql workbench?

It will open the data export settings and options window as shown below. The left section on the window displays all the existing databases on our MySQL database server. When we select a database by clicking on it, it will display all the respected tables under the selected database. We can select one or more database check-boxes to include the database in the Export file. We can also select one or more tables from the right section of this window.

How do i export only data from mysql workbench?

So, let’s select our school database which we created earlier. And in the right-side pane, select the students and studentaddress table as shown in the below image.

How do i export only data from mysql workbench?

In the drop-down setting, we can select ‘Dump Structure Only’, ‘Dump Data Only’ or ‘Dump Structure and Data’ option. The ‘Dump Structure Only’ option will save only the table structure. That is database columns and data types defined by us. While ‘Dump Data Only’ option will save only the inserted rows in the tables. The Dump Structure and Data option will save both data and structure. Let’s choose the ‘Dump Structure and Data’ option to save both table structure and data rows in it as shown in the below image.

How do i export only data from mysql workbench?

Under the Export Options section, you can change the default export path of your choice and I am going with the default one. Also, there are two radio buttons. By selecting the first option that is ‘Export to Dump Project Folder’, MySQL Workbench will save all the tables as separate SQL files under one folder which is useful when you will be importing or restoring the export file one by one table. The second option Export to Self-contained File will store all the databases and tables in a single SQL file. This is a good option when you will be importing all the databases, tables, and data rows by using a single SQL file. We will export the database using both the method, to understand the difference. Let’s export the database using the first option ‘Export to Dump Project Folder’ as shown in the below image.

How do i export only data from mysql workbench?

Finally, click on the start export button to start export functionality as shown in the below image.

How do i export only data from mysql workbench?

Once you click on the start export button it will display the progress bar and log as shown in the below image.

How do i export only data from mysql workbench?

Now, if you go to the location where it saved the file, then you will see multiple SQL files which are nothing but individual tables as shown in the below image.

How do i export only data from mysql workbench?

Now again go to the Server => Data Export window and this time select Export to self-contained file option and click on the Start Export button as shown in the below image.

How do i export only data from mysql workbench?

Once the Export did successfully, go to the folder location where this file saved and you will see under the dumps folder, we have a single dump file that includes all the databases and tables, and data rows as shown in the below image.

How do i export only data from mysql workbench?

Import Database using MySQL Workbench

Before Importing the database, let us first delete the tables which are already there in the school database by executing the below SQL statement.

DROP TABLE school.studentaddress;
DROP TABLE school.students;

Now let’s learn how to import the database and tables using the MySQL workbench. Go to the top ‘Server’ menu and select the ‘Data Import’ option as shown in the below image.

How do i export only data from mysql workbench?

It will open the ‘Data import’ window which is exactly opposite to the data export window as shown in the below image. Here you can either Import from the dump project folder or import by using a single self-contained file.

How do i export only data from mysql workbench?

Here, I am Selecting Import from Dump project folder radio button option, and then I will select the dump project folder location where we saved the file while exporting as shown in the below image.

How do i export only data from mysql workbench?

Once you select the Import from Dump project folder, then click the ‘Load Folder Content’ button to display all the available databases in the ‘project folder’ as shown in the below image.

How do i export only data from mysql workbench?

Next, select the school database from the left pane and select the tables that you want to import from the right-hand side, select the Dump Structure and Data option from the drop-down list, and then click on the Select Tables and finally click on the Start Import button as shown in the below image.

Once you click on the Start Import button, it will import the data and if the import completed successfully, then you will get the below window.

How do i export only data from mysql workbench?

Now again under the schemas option, go to the school database, and under the tables tab clicks ‘refresh’ and you can see students and studentaddress tables appear again as shown in the below image.

How do i export only data from mysql workbench?

In this way, we can export and import a single database table or multiple tables using MySQL Workbench ‘Data Export’ and ‘Data Import’ options.

In the next article, I am going to discuss Data Types in MySQL with Examples. Here, in this article, I try to explain how to Export and Import MySQL Database using MySQL Workbench and I hope you enjoy this Export and Import MySQL Database using MySQL Workbench article.

How do I export data from MySQL Workbench?

Create a backup using MySQL Workbench.
Connect to your MySQL database..
Click Server on the main tool bar..
Select Data Export..
Select the tables you want to back up..
Under Export Options, select where you want your dump saved. ... .
Click Start Export. ... .
You now have a backup version of your site..

How do I extract data from a workbench?

Export table data.
In the Navigator, right click on the table > Table Data Export Wizard..
All columns and rows are included by default, so click on Next..
Select File Path, type, Field Separator (by default it is ; , not , !!!) and click on Next..
Click Next > Next > Finish and the file is created in the specified location..

How do I export selected data in MySQL?

Exporting Data with the SELECT ....
The output file is created directly by the MySQL server, so the filename should indicate where you want the file to be written on the server host. ... .
You must have the MySQL FILE privilege to execute the SELECT ... ... .
The output file must not already exist..

Can we export data using Workbench?

The Data Export MySQL Workbench feature provides an inbuilt option to export the data into CSV format.