Backups with mysqldump & Restoring

📄 MySQLLesson 14Advanced

Backing up databases ensures safety against server failures, file corruption, or database drops.

1 Backup and Restore Operations
Shell — Backup Commands
# Export database schema and records to sql script
mysqldump -u root -p library_db > backup.sql

# Backup all databases
mysqldump -u root -p --all-databases > all_backup.sql

# Import / Restore SQL script
mysql -u root -p library_db < backup.sql
2 Code Challenge
Challenge: Export your ecommerce_db using mysqldump, drop the database, recreate it, and restore the export script verifying that all fields are restored.