Skip to main content

Backing up and restoring mySQL databases

·1 min

I’m always hunting around for backup and restore commands when migrating my WordPress blogs. I use these commands frequently when backing up or restoring mySQL databases.



Backing up the contents of your mySQL database to a sql file:

mysqldump -u username -p databasename > backupfile.sql


Restoring contents from a sql file to a mySQL database.

mysql -u username -p databasename < backupfile.sql

Obviously these are simple versions of the commands. Please consult the WordPress documentation for all the options on these commands.