O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

REPLACE with new data

Suppose you want to restore data from the production database to a development machine that already has some data. If you want to merge the data from production with development, you can use the --replace option, which will use the REPLACE INTO statement instead of the INSERT statement. You should also include the --skip-add-drop-table option, which will not write a DROP TABLE statement to the dump file. If you have the same number of tables and structure, you can also include the --no-create-info option, which will skip the CREATE TABLE statement in the dump file:

shell> mysqldump --databases employees --skip-add-drop-table --no-create-info --replace > to_development.sql

If you have some extra tables in production, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required