Would you like to learn how to backup a database on MySQL? In this tutorial, we are going to show you how to use the MySQL command-line to backup a database.

• Ubuntu 20.04
• Ubuntu 19.04
• Ubuntu 18.04
• MySQL 8.0.19

Equipment list

The following section presents the list of equipment used to create this tutorial.

As an Amazon Associate, I earn from qualifying purchases.

Tutorial MySQL - Backup a database

Access the MySQL command-line.

Copy to Clipboard

Verify the list of databases.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

In our example, a user account named AAA01 has permission over the database named MYDATABASE.

Copy to Clipboard

On the Linux command-line, backup the MySQL database.

Copy to Clipboard

Verify the content of the MySQL backup file.

Copy to Clipboard

Here is the file content.

Copy to Clipboard

Congratulations! You created a MySQL database backup.

Tutorial MySQL - Restore a database

On the Linux command-line, restore the MySQL database backup.

Copy to Clipboard

Access the MySQL command-line.

Copy to Clipboard

Verify the list of databases.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Configure the user permission over the restored MySQL database.

Copy to Clipboard

In our example, a user account named AAA01 has permission over the database named MYDATABASE.

Access the MySQL command-line using the new account.

Copy to Clipboard

Verify the data on a MySQL table.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

In our example, we restored a MySQL database name DATABASE.

Congratulations! You are able to restore a MySQL database.