Home / Linux / How to Restore MySQL Backups

How to Restore MySQL Backups

Restore a MySQL dump safely into a database, including decompression, import commands, and verification queries.

Views: 16 Unique: 13 Updated: 2026-03-19

What this is

This guide explains how to restore a MySQL/MariaDB backup created with mysqldump.

What it is for

  • Recover data after a mistake
  • Move a database to another server

Prerequisites

  • Backup file (.sql or .sql.gz)
  • MySQL/MariaDB installed on the target
  • Credentials with privileges to create/import

Step-by-step

Step 1) If compressed, decompress

gunzip -k appdb_backup.sql.gz

Step 2) Create the target database (if needed)

sudo mysql -e "CREATE DATABASE appdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"

Step 3) Import the dump

mysql -u appuser -p appdb < appdb_backup.sql

Expected output: Usually silent. Errors will print to the screen.

Step 4) Verify data

mysql -u appuser -p -e "SHOW TABLES;" appdb

Warnings & notes

  • Restoring overwrites existing tables if the dump contains DROP/CREATE statements.
  • For large imports, it can take time; run it inside a screen/tmux session.

Conclusion

You restored a MySQL backup successfully. Next step: verify the application connects and consider automated backups.

Back to category