Search code examples
mysqldatabaseimportphpmyadminexport

Import some database entries through PHPMyAdmin with overwrite


I exported a couple of entries from a database I have stored locally on my MySQL dbase through PhpMyAdmin and I'd like to replace only those entries on my destination database hosted online. Unfortunately when I try to do so PHPMyAdmin says that those posts already exist and therefore he can't erase them.

It'll take me a lot of time to search for those entries manually within the rest of the posts and delete them one at a time so I was wondering if there's any workaround in order to overwite those entries on import.

Thanks in advance!


Solution

  • A great option is to handle this on your initial export from phpMyAdmin locally. When exporting from phpMyAdmin:

    1. Export method: Custom
    2. Format: SQL
    3. Format-specific options - choose "data" (instead of "structure" or "structure and data")
    4. In Data creation options - Function to use when dumping data: Switch "Insert" to "Update" <-- This is the ticket!
    5. Click Go!

    Import into your production database. (always backup your production database before hand just in case)

    I know this is an old post, but it actually helped me find a solution built into phpMyAdmin. Hope it helps someone else!