How to backup and restore a MySQL database Print

  • 2


  • A Linux operating system.
  • MySQL installed (install MySQL on Ubuntu, CentOS 7, CentOS 8).
  • An existing database.

How to make a backup of the MySQL database?

You can make a backup of a MySQL database using command-line tools.


Method 1: Making a backup of the MySQL database using mysqldump
mysqldump is MySQL's native backup solution. It allows the user to create a backup with a single command. The syntax is:

sudo mysqldump -u username -p dbname > backup.sql 
  • Replace the username with your MySQL username.
  • dbname is the name of the database you want to backup.
  • Replace backup.sql with the desired name for the backup file.

For example:

Method 2: Making a backup of the MySQL database using phpMyAdmin
phpMyAdmin utilizes the Export function to create backups. Follow the steps below:

1. Open phpMyAdmin. In the directory tree on the left, click on the database you wish to backup.

Doing so opens the directory structure in the right window. You'll also notice that all assets of the main database are highlighted in the directory tree.

2. Click on the Export tab.

3. Select Quick in the Export method section to save a copy of the entire database. Choose Custom to select individual tables or other special options. Leave the Format field set to SQL unless you have a good reason to change it.

4. Click on Go to start the process.

If you selected Quick, the web browser will download a copy of the database to the specified download folder. You can then copy it to a secure location.

Was this answer helpful?

« Back

Powered by WHMCompleteSolution