How do I backup a MariaDB - MySQL Database?

PHP/MySQL | Updated 2026

Backing up your database is essential before making changes to your website, updating plugins, or migrating to a new server. Ultra Web Hosting gives you several ways to create database backups, from a quick download in phpMyAdmin to automated cron-based backups.

01. Backup via phpMyAdmin

  1. Log into cPanel and open phpMyAdmin (under Databases)
  2. Select your database from the left sidebar
  3. Click the "Export" tab
  4. Select "Quick" for default settings (exports all tables as SQL)
  5. Click "Go" to download the .sql file

For larger databases or specific needs, choose "Custom" export which lets you select specific tables, add DROP TABLE statements (useful for clean restores), compress the output as gzip or zip, and choose the SQL compatibility mode.

Tip

When using Custom export, check "Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGER statement." This makes the backup file self-contained: when you import it later, it will drop existing tables first, preventing duplicate key errors.

02. Backup via cPanel Backup Tool

  1. Log into cPanel
  2. Go to Files > Backup (or "Backup Wizard" for a guided process)
  3. Under "Download a MySQL Database Backup", click the name of the database you want to download
  4. The compressed .sql.gz file downloads to your computer

This is the same data as a phpMyAdmin export but compressed, which is faster for large databases. The cPanel backup tool also lets you download a full account backup (files + databases + email) in one shot. See How to Back Up Your Website for the full backup guide.

03. Backup via SSH (mysqldump)

If you have SSH access, mysqldump is the most powerful backup method:

mysqldump -u dbuser -p dbname > ~/backup_$(date +%Y%m%d).sql

Replace dbuser with your database username and dbname with the database name. You will be prompted for the password. The backup file is saved to your home directory with today's date in the filename.

To create a compressed backup:

mysqldump -u dbuser -p dbname | gzip > ~/backup_$(date +%Y%m%d).sql.gz

To find your database username and password, check your site's configuration file (e.g., wp-config.php for WordPress).

04. Automated Backups With Cron

You can set up a cron job to back up your database automatically on a schedule. See How to Create a Cron Job for setting up cron jobs in cPanel.

Example cron command that backs up daily and keeps the last 7 days:

mysqldump -u dbuser -p'yourpassword' dbname | gzip > ~/backups/db_$(date +\%Y\%m\%d).sql.gz && find ~/backups -name "db_*.sql.gz" -mtime +7 -delete
Security Note

The cron example above includes the password in the command line, which is visible in process listings. For better security, store your credentials in a ~/.my.cnf file with permissions set to 600. Then mysqldump will read the credentials automatically without exposing them.

05. How to Restore a Backup

Via phpMyAdmin

  1. Select your database in phpMyAdmin
  2. Click the "Import" tab
  3. Click "Choose File" and select your .sql or .sql.gz file
  4. Click "Go"

Via SSH

mysql -u dbuser -p dbname < ~/backup_20260325.sql

For compressed backups:

gunzip < ~/backup_20260325.sql.gz | mysql -u dbuser -p dbname

Need Help With Database Backups?

If you need help creating or restoring a database backup, or if you need us to restore from a server-level backup, open a ticket.

Open a Support Ticket

Quick Recap

  1. phpMyAdmin - Fastest for one-off backups (Export tab > Quick > Go)
  2. cPanel Backup - Downloads compressed backups under Files > Backup
  3. mysqldump via SSH - Most flexible, scriptable for automation
  4. Automate with cron - Schedule daily backups and auto-delete old ones
  5. Always back up before making changes - Updates, migrations, and plugin installs

Protecting your data with regular backups · Last updated March 2026 · Browse all PHP/MySQL articles

  • 446 Users Found This Useful

Was this answer helpful?

Related Articles

Learn About MariaDB

PHP/MySQL | Updated 2026 Ultra Web Hosting uses MariaDB as the database server on all shared...

Increase PHP Memory

PHP/MySQL | Updated 2026 If your website shows a "Fatal error: Allowed memory size exhausted"...

What is the Path to ImageMagick?

PHP/MySQL | Updated 2026 ImageMagick is installed on all Ultra Web Hosting servers and is...

Test MySQL Connection

PHP/MySQL | Updated 2026 If your website shows database connection errors, you need to verify...

Running a PHP file with a cron job

PHP/MySQL | Updated 2026 You can schedule PHP scripts to run automatically at set intervals...



Save 30% on web hosting - Use coupon code Hosting30