Skip to content

Creating a Database Backup and Restoration

A database backup (also known as a dump) can be created and restored in two ways:

  • via command line over SSH,
  • via the web interface phpMyAdmin (PMA)

Creating a Backup via Console (SSH)

Connect to the server via SSH and run the following command:

mysqldump -u'username' database_name -p'password' > backup_file.sql

Replace username, database_name, password, and backup_file.sql with your own data.
The file backup_file.sql will appear in the current directory on the server — that’s your backup.


Creating a Backup via phpMyAdmin

Full database export:

  1. In the left pane of phpMyAdmin select the desired database — a list of its tables will appear.
  2. Go to the Export tab.
  3. Click Next — the database copy file will download to your computer.

Exporting only selected tables:

  1. Select the database on the left.
  2. Tick the boxes next to the tables you want.
  3. At the bottom of the page, in the With selected: dropdown, choose Export.
  4. Make sure the format is SQL, then click Next. The file will be saved to your computer.

Restoring via Console (SSH)

To load the backup into the database, run:

mysql -u'username' database_name -p'password' < backup_file.sql

Note

Make sure the database already exists on the server. This command simply streams the data from the file into the specified database.


Restoring the Database via phpMyAdmin

  1. In the left pane select the database into which you want to load data.
  2. Go to the Import tab.
  3. Click Choose File and select the downloaded dump.
  4. Other settings (charset, format, etc.) can remain at their defaults.
  5. Click Next — the data will be loaded into the database.

Note

phpMyAdmin often struggles with files larger than 1 GB. If your dump is large, it’s better to restore it via the console.

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×