How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?

It is that simple for WordPress too. I use the following to back up my WP sites:

mysqldump -u <user> -p<pass> --quick --extended-insert <db-name> > backup.sql

The mysqldump document gives the details on all the parameters.

--extended-insert is quicker when updating a DB from a dump file and makes the dump file smaller.

--quick makes the creation of the dump quicker.

You don’t really need to use either of those, just makes things a bit quicker and writing an insert for each row just makes me feel happier – your original dump syntax would be just fine.

Don’t forget though that there is domain-specific entries in the DB so if you are using this method to backup/restore then you are fine but if you want to move from one.com to two.com then you will need to edit entries in wp_options after you restore your dump.

Leave a Comment