How to export a database in cPanel (phpMyAdmin)

An export (dump) is a .sql file with all tables and data of a database. You need it before updating the CMS or plugins, before moving the site to another host, and to hand a copy of the database to a developer.

Which database the site uses

The database name is in the site settings file: in WordPress it is the line define('DB_NAME', ...) in wp-config.php. All databases of the account are listed in "Manage My Databases". The name always starts with the account prefix, for example example_wp.

With phpMyAdmin

  1. Open "phpMyAdmin".
  2. Select the database on the left.
  3. Open the "Export" tab.
Database in phpMyAdmin
Database in phpMyAdmin
  1. "Export method" - "Quick".
  2. "Format" - SQL.
  3. Click "Export". The file downloads to your computer.
Exporting a database
Exporting a database

The "Custom" method shows more options:

  • gzipped compression - the file is several times smaller and downloads faster;
  • table selection - export only the tables you need instead of the whole database;
  • adding DROP TABLE statements - when the dump is loaded into a non-empty database, old tables are replaced instead of causing a "table already exists" error.

A single table can also be exported this way: click it on the left and open the "Export" tab.

With Backup

In "Backup" (group "Files"), block "Download a Database Backup", click the database name to download its dump as .sql.gz. For large databases this way is more reliable: the dump is prepared in full and does not break off halfway, as browser exports sometimes do.

Downloading a database dump
Downloading a database dump

Check the dump

Open the file in a text editor (unpack .sql.gz first): near the top there should be CREATE TABLE lines, followed by INSERT INTO lines with data. A file of a few kilobytes for a live site database means the export broke off or the wrong database was chosen.

A dump contains all site data, including users and orders. Do not leave it in public_html - download it to your computer and delete it from the hosting. Keep it as carefully as passwords.

Common mistakes

  • CSV format was chosen instead of SQL - such a file cannot be loaded back as a database.
  • The wrong database was exported: the account has several, the right one is named in the site settings.
  • The dump for a shop move was made in advance - orders placed after the export are not in it. Make the dump as the last step, right before switching the domain.

To load a dump back, see importing a database.

Questions and answers
Choose the "Custom" export method with gzipped compression, or download the database in "Backup".
In the CMS settings file. In WordPress it is the DB_NAME line in wp-config.php.
Not for a live site: the export broke off or the wrong database was chosen. Download the database through "Backup".