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.