I can restore from

mysqldump wordpress-db > mysqldump-wpdb.sql

to new DB fine with

$ sudo mysql wordpress-db001 < mysqldump-wpdb.sql

But if the DB already exists (as they generally do with a restore...!), I get error:

ERROR 1050 (42S01) at line 2084: Table 'wp_commentmeta' already exists

I don't think it's anything to do with permissions of root (ie used by sudo), just a standard problem. The error makes sense and is a good warning, but I can't find where to simply overwrite or DROP all the existing objects - does that have to be coded manually into the .sql or is there an easier way to do this?


1 Answer 1


Why can't you just add this option in the mysqldump? --add-drop-database --databases <db_you_want_to_dump>

  • Because didn't expect to have to pre-emptively specify option in backup as opposed to restore. By which time it's too late. Plus sometimes backups via phpMyAdmin, again without this option included. Also, the idea of deleting entire DB to do a restore is anathema to me - esp on production systems where suddenly the DB becomes MIA. Am used to MS SQL Server where you can specify WITH REPLACE which effectively overwrites without DROP (or having to set an option in backup). Just looking for MySQL best practice, thanks for the answer, does seem the only way, together with similar --add-drop-table. Jul 13 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.