Home / Blog / Web Hosting / How to Take a MySQL Database Backup in cPanel
How to Take a MySQL Database Backup in cPanel
Web Hosting

How to Take a MySQL Database Backup in cPanel

Regular database backups are the safety net every website owner needs. Whether you're migrating to a new host, updating your CMS, or recovering from a hack, having a fresh .sql backup can save your entire business. This guide covers three reliable methods to back up your MySQL database in cPanel.

Method 1 — cPanel Backup Wizard (Easiest)

The Backup Wizard is the simplest option for non-technical users.

  1. Log in to cPanel.
  2. Go to Files → Backup Wizard.
  3. Click Back Up, then select MySQL Databases.
  4. Choose the database you want to back up.
  5. Click Generate Backup — a .sql.gz file will download to your computer.

Method 2 — Export via phpMyAdmin

  1. In cPanel, open phpMyAdmin.
  2. Select your database from the left sidebar.
  3. Click the Export tab.
  4. Choose Quick export method and SQL format.
  5. Click Go — the .sql file will download immediately.

Tip: For large databases, use the Custom export method and enable gzip compression to reduce file size.

Method 3 — mysqldump via SSH (Most Powerful)

This method is best for large databases and automated backups.

mysqldump -u username_dbuser -p username_dbname > ~/backup_$(date +%F).sql

To create a compressed backup:

mysqldump -u username_dbuser -p username_dbname | gzip > ~/backup_$(date +%F).sql.gz

The $(date +%F) appends today's date to the filename automatically (e.g., backup_2025-05-10.sql.gz).

Automating Backups with a Cron Job

Set up a daily automated backup by adding a cron job in cPanel:

  1. Go to Advanced → Cron Jobs.
  2. Set the schedule to Once a day.
  3. Enter the command:
mysqldump -u username_dbuser -pYourPassword username_dbname | gzip > ~/backups/db_$(date +\%F).sql.gz

Security note: Storing the password in a cron command is not ideal. Use a ~/.my.cnf file to store credentials securely.

Where to Store Your Backups

  • Never store backups only inside public_html — they could be publicly accessible.
  • Download backups to your local computer after each export.
  • Use cloud storage (Google Drive, S3, Dropbox) for off-site redundancy.
  • Keep at least 30 days of rolling backups for critical databases.

Need help automating your backups or setting up a backup policy? Contact the Flyhost support team — we're happy to assist.