Restores a MySQL dump file so the original schema and data become available again.
Restoring re-creates all tables, indexes, and data from a dump file produced by mysqldump
or a physical snapshot. The process writes the SQL statements in the dump into the target database exactly as they were when the backup was taken.
mysql client is the most common. For huge files, mysqlpump, myloader/mydumper, or Percona XtraBackup speed things up. GUI tools like Galaxy, TablePlus, or DBeaver wrap the same commands under the hood.
1️⃣ Create the empty target database if it doesn’t exist.
2️⃣ Disable foreign-key checks for faster load.
3️⃣ Pipe the dump file into mysql
while supplying credentials. Example below loads ecommerce.sql
back into ecommerce_prod
.
mysql -u root -p ecommerce_prod < ecommerce.sql
Use --one-database
with a filtered dump or run SOURCE
for each table-specific file if you dumped tables individually.
Run quick row counts: SELECT COUNT(*) FROM Customers;
or spot-check totals such as SELECT SUM(total_amount) FROM Orders;
and compare them to the source environment or audit logs.
Increase innodb_buffer_pool_size
temporarily, disable binary logging, and load with --disable-keys
. Re-enable constraints and logging afterward.
Not directly; run pgloader
or migra
to convert the MySQL dump to PostgreSQL-compatible SQL first, then execute the generated file with psql
.
• Restore to a staging database first.
• Run integrity checks and application smoke tests.
• Take a fresh backup of the target before overwrite.
• Automate the task in CI/CD so procedures are repeatable.
See below for the two most frequent errors and fixes.
--force
safe to use during restore?Only as a last resort; it ignores errors that might hide data loss. Prefer fixing the root cause.
Yes: gunzip < ecommerce.sql.gz | mysql -u root -p ecommerce_prod
.
Only if the dump lacks DROP TABLE IF EXISTS
statements. Otherwise, MySQL will replace objects automatically.
Not natively. Use mydumper/myloader or split your dump into smaller chunks that you can replay individually.
Pass the password via an environment variable, --password
flag, or use a ~/.my.cnf
file with proper file permissions.