MySQL + SQL · Lesson 103
MySQL Backup and Restore
Why Backups?
A backup is a saved copy of your database. Restoring it recovers data after accidental deletion, corruption or server failure.
Take a Backup (mysqldump)
mysqldump -u root -p school > school_backup.sqlThis creates an .sql file with all CREATE and INSERT statements.
Restore a Backup
mysql -u root -p school < school_backup.sql
Best Practice
Follow the 3-2-1 rule: 3 copies, 2 different media, 1 offsite. Automate daily backups.
Summary
- mysqldump creates a .sql backup; restore by importing it back.
- Automate regular backups; keep copies in more than one place.