1. Overview

In this short tutorial, we'll see how to easily backup MySQL Database. We will cover two ways which work on Ubuntu and Windows.

There are different types of backups. In this article we will do full logical backup - SQL script for creation of the same DataBase - like table structure and data.

2. Backup MySQL with mysqldump

MySQL has a backup utility called mysqldump which is installed by default. It creates a dump SQL file with content of some or all databases.

2.1 Backup all MySQL databases

To create MySQL backup with in one line use:

mysqldump --user root --password  --all-databases > full_backup.sql

2.2 Backup single MySQL database

To do backup of a single database use the following syntax:

mysql --user root --password db_name < database.sql

2.3 Recover MySQL database

To recover single or all MySQL databases we can use syntax like:

mysql --user root --password mysql < full_backup.sql

Since the dump file is a SQL script it can be used with different MySQL versions. Be careful that in some cases this might lead to inconsistencies.

3. Backup MySQL using HeidiSQL

HeidiSQL is a free and easy to use tool. It works both on Linux and Windows and can be installed from here: Download HeidiSQL 11.3. For Linux it can be installed with wine.

To backup MySQL database use these steps:

  • Right click the database
  • Export as SQL
  • Select database(s)
  • Select export options
    • Select Create tables
    • Data - select Insert if you like to backup your data
    • Output - select the output - clipboard, SQL script or database
  • Export

See the image below:

4. Conclusion

This article shows how to do a quick and full backup of your MySQL DataBase. We saw two different ways - by mysqldump tool or by using a free UI app.