MySQL - Restore dumpfile replace syntax?

Posted on 2009-02-20
Last Modified: 2012-05-06
Is there a way to restore a dumpfile using mysql dbname < dumpfile.sql and tell it to replace the row in the event duplicate data is found?
Question by:jen_jen_jen
    1 Comment
    LVL 26

    Accepted Solution

    I don't think you can do this while running command..

    mysql dbname < dumpfile.sql

    Instead while taking dump using mysqldump you can specify parameter --insert-ignore which take cares if any duplicate error thrown.

    Or you can simply replace INSERT INTO with INSERT IGNORE INTO in the dump file

    Some ppl might suggest to use REPLACE INTO instead of INSERT IGNORE but beware for InnoDB tables that might cause problems if its primary key is referenced somewhere...

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
    Creating and Managing Databases with phpMyAdmin in cPanel.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now