Monday, August 10, 2026

Exporting and Importing all MySQL databases

If you are having troubles in importing mysql dump file, then re-export source mysql with the --add-drop-table and --add-drop-database flags. This forces the backup file to clean up the target server automatically during import.


Export with drop flag

mysqldump -u root -p --all-databases --single-transaction --add-drop-table --add-drop-database > all_databases_backup.sql


Import normally:

mysql -u root -p < all_databases_backup.sql

Use code with caution.