EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials MySQL Tutorial MySQL Export Database
 

MySQL Export Database

Payal Udhani
Article byPayal Udhani
EDUCBA
Reviewed byRavi Rathore

Updated May 29, 2023

MySQL Export Database

 

 

Introduction to MySQL Export Database

In MySQL, we store the data in the database in table format. Many times, it becomes necessary to obtain the data stored in MySQL database tables in formats such as CSV, JSON, or SQL. Such conversions are often required when data needs to be transferred and shared among multiple companies and individuals.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Suppose we have the exported data of the database and its table contents in CSV format. In that case, this data can be further used in other platforms such as google docs, open office, or Microsoft Excel for further analysis of the resultset and concluding the necessary statistics by performing various operations on the exported data to get certain conclusions. When exporting MySQL data in JSON format, we can transfer this data to other applications because JSON is the most preferred method for data transfer. Moreover, you can export or dump MySQL data to SQL files, which can function as backup files. You can execute the exported commands for the specific database or table contents on either a different or the same MySQL server to restore the database to a state that closely resembles the state at the time of data export.

In this article, we will learn how we can export the data of MySQL to various formats when using the MySQL Workbench editor. The mysqldump command can also export data to SQL format through the command line. Other than this, we can use the INTO OUTFILE statement to export the data of MySQL database and its contents to any other format like .csv or .txt using the command-line MySQL shell.

Exporting Database and tables in Workbench in SQL format

You can choose the option “Data Export” provided in the Management wizard on the first screen on MySQL workbench or go to the Server menu in the upper portion and then choose the option Data Export to open the Export wizard of MySQL as shown below

MySQL export database

Here, you can select the database whose contents or the whole database you want to export. After you click on the desired database name, you will notice that all the tables inside it are automatically selected in the right-side window, as depicted in the image below. Clicking on the “educba” database will result in the selection of all the tables contained within in the right window. You can keep it as it is if you want to export entire database contents or choose the table or tables you wish to export and click the start export button to initialize the export process.

MySQL export database 1

After clicking start export, the MySQL dump file in .sql format will be created on the specified export options path.

Exporting data to any other format in Workbench

You can export the table contents and structure by going to the schemas tab in the Workbench tool’s left sidebar. Then you can right-click on the table of the database you wish to export and then click on “Table Data Export Wizard,” which will lead to the opening of the export wizard as shown in the below image. You will observe that the list of all the columns of that table is automatically selected for exporting. You can choose the columns you want to export by changing the selected columns and then click on the Next button at the bottom, as shown below.

MySQL export database 2

If you click the advanced button below, you can type the equivalent query whose resultant data and content will be exported. Once you click on the next button, you will have the option to select the path where the file should be exported and choose the desired format, either CSV or JSON. If you choose CSV, you can select specific options related to the data to be exported and specify various properties for the export process. These properties may include the field separator to be used and how to interpret the NULL value, among others. The image below demonstrates these options.

MySQL export database 3

After clicking Next, if the same file with the same name and format exists on the specified path, it asks whether you want to overwrite the file or mention the steps that will be followed and executed while exporting, as shown below.

MySQL export database 4

After clicking next, you will see a message that the file has been exported successfully, as shown below.

File exported 5

After running the export process successfully, you can observe that the exported file in the desired format will be created in the specified path.

Exporting the Query Resultset

There is also the provision to export the resultset of any select query executed in Workbench by simply clicking on the export button and then specifying the path and name of the file. Note that in MySQL, using the command line, we can export the query results by using the INTO OUTFILE statement. Let us look at how we can export the resultset of the query in the workbench with the help of an example. Consider the following select query that retrieves the names of all developers that begin with the letter R, as shown below –

select * from developers where name like "R%";

that gives the following output after the execution of the query –

Exporting the Query Resultset

Now, we can click on the export button that turns into opening the files, and we can choose the path and name of the file by typing in it as shown below

MySQL Workbench 1

You can choose the report format from CSV, HTML, XML, JSON, SQL, or Excel whichever you want, from the choice list provided below in the left-hand corner. , click on the save, and your file will be exported with the retrieved result set.

Conclusion – MySQL Export Database

We can export the database, table contents, and structure or the output resultset of the MySQL query in MySQL using the client tools of MySQL like Workbench or even using the command-line mysqldump command to create .sql exported files or using INTO OUTFILE statement.

Recommended Articles

We hope that this EDUCBA information on “MySQL Export Database” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. MySQL Split
  2. EXISTS in MySQL
  3. MySQL DELETE Trigger
  4. MySQL Query Cache

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - ENROLL NOW