Shared hosting

How to export/import a MySQL database?

2014-02-20

A database dump is useful for a backup, for moving a site or for restoring data. You can export and import it in three ways: in the panel, in phpMyAdmin or over SSH.

In the panel (recommended)

Export:

  1. Open "Main" -> "Databases".
  2. Select the database and click "Dump": the browser downloads the dump file.

How to export/import a MySQL database?

Import:

  1. Open "Main" -> "Databases".
  2. Select the database and click "Import".
  3. Choose a .sql file or a compressed .sql.gz file.

Import loads the data into the selected database. If the database already has tables with the same names, delete them first (for example in phpMyAdmin) or use a dump with DROP TABLE commands.

Compress large dumps to .sql.gz: the panel accepts compressed files. If a dump is over the upload limit, the panel tells you.

In phpMyAdmin

  1. Open phpMyAdmin (see "How to open phpMyAdmin?") and choose the database.
  2. Export: "Export" tab -> "Go".
  3. Import: "Import" tab -> choose the file -> "Go".

Over SSH

The first command saves the database to dump.sql, the second loads it back:

mysqldump -u USER -p DB_NAME > dump.sql
mysql -u USER -p DB_NAME < dump.sql

How to connect over SSH: see "How to connect via SSH".