export database

How to Export MySQL Database in Window and Linux

  • Profile picture of Mcs
  • by Mcs June 27, 2025

Prerequisites

Exporting MySQL Database With mysqldump

MySQL includes the mysqldump command that creates a dump file with all the data related to the specified database. Once generated, the file can be shared or used as a backup.

Follow the steps below to export a MySQL database to a dump file:

1. Enter the following command in a terminal Window, replacing [database] with the database name and [dump-file] with a custom name for the SQL file:

mysqldump –u root –p [database] > [dump-file].sql

2. Confirm the export in Linux by entering:

head –n 5 [dump-file].sql

Exporting MySQL Database Using phpMyAdmin

Server and site management platforms, such as cPanel, often include phpMyAdmin, a webUI program for managing web servers. If you have access to cPanel and want to export a database from a web server, follow the steps below to perform this action with phpMyAdmin:

1. Log into cPanel.

2. In the Databases section, select phpMyAdmin.

cpanel

3. Select the database to export in the menu on the left side of the main phpMyAdmin window. Wait for the database to load.

4. Select the Export tab from the tab bar at the top of the window.

5. Set the export method to Quick.

6. Ensure the export format is SQL.

7. Select Export to download the dump file to the local system.

phpmyadmin

Exporting a MySQL Database via MySQL Workbench

MySQL Workbench is a GUI tool for MySQL database management, available for Linux, Windows, and macOS. Proceed with the following steps to export a dump file using MySQL Workbench:

1. Launch MySQL Workbench and connect to the MySQL database.

2. Select the Server item in the menu bar.

3. Choose Data Export from the menu.

workbench

4. Select the databases to export in the Expo Schema section.

5. Choose the Export to Self-Contained File option in the Export Options section.

6. Click the Start Export button to start the process.

workbench