Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 928
MACC Avatar asked Aug 30 '12 16:08

MACC


People also ask

How can I copy database from one database to another in phpMyAdmin?

Select the database you wish to copy (by clicking on the database from the phpMyAdmin home screen). Once inside the database, select the Operations tab. Scroll down to the section where it says Copy database to. Type in the name of the new database.


1 Answers

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!

like image 145
Matt Mintun Avatar answered Oct 01 '22 21:10

Matt Mintun