php - Phpmyadmin export issue -
my shared host not allow ssh access. trying export database using phpmyadmin , import onto new server. keep getting error , not sure how fix it. appreciated.
error sql query: -- -- indexes dumped tables -- -- -- indexes table `ewrporta_blocks` -- alter table `ewrporta_blocks` add primary key ( `block_id` ) , add key `title` ( `title` ) ; mysql said: documentation #1068 - multiple primary key defined
i have run issue multiple times, , modonoghue has 1 valid way of handling dropping tables , recreating them.
problem & general solution
basically happening trying run insert statements inserting values primary keys exist - thereby giving error of duplicate keys. database has no clue how handle having multiple entries same key, sql logic based around every 'row' having primary key unique.
what want save values exported sql file, in query that, when import file again, deletes existing values (assuming want restore point , aren't worrying data saved between export date , import date!) , inserts exported values ... or somehow else avoids trying add new entry existing key (see following).
one method export specific database (truncate):
- in other words, when using phpmyadmin export sql file, click "custom - display possible options".
- under "format-specific options" make sure "structure , data" selected (otherwise may end dropping tables , not having data restore them with!!!)
- under "data creation options" select "truncate table before insert" -- delete existing data in tables.
when import, existing data deleted each table (truncate) , exported data written tables (insert) tables won't deleted (drop).
ignore vs truncate (alternative route)
you should able skip step 3 above (truncate) , instead select checkbox "instead of insert statements use ..." "insert ignore statements"
basically, "ignore" skip on duplicates in exported data, , prevents having delete existing data. if want add lost data, without deleting data that's been changed / added since last export.
superuser (on duplicate key update)
there insert ... on duplicate key update ... allows tell query if there duplicate key. prevents ignoring 2 entries identical keys may not identical entries. more complicated setup properly, however.
Comments
Post a Comment