My shared host does not allow SSH access. I am trying to export a database using phpmyadmin and import onto a new server. I keep getting this error and i am not sure how to fix it. Any help is appreciated.
Error
SQL query:
--
-- Indexes for dumped tables
--
--
-- Indexes for 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 into this issue multiple times, and modonoghue has one valid way of handling it by dropping your tables and completely recreating them.
Basically what is happening is that you are trying to run INSERT statements that are inserting values into primary keys that already exist - thereby giving you an error of duplicate keys. The database has no clue how to handle having multiple entries with the same key, as SQL logic is based around every 'row' having a primary key that is completely unique.
What you want to do is to save all the values to your exported sql file, in a query that, when you import the file again, deletes all the existing values (assuming you want to restore it to a certain point and aren't worrying about data saved between your export date and your import date!) and inserts all the exported values ... or somehow else avoids trying to add a new entry with an existing key (see following).
When you import, all the existing data will be deleted from each table (TRUNCATE) and all the exported data will be written back to the tables (INSERT) but the tables themselves won't be deleted (DROP).
You should be able to skip Step 3 above (TRUNCATE) and instead select the checkbox "Instead of INSERT Statements Use ..." "INSERT IGNORE statements"
Basically, "IGNORE" will just skip over duplicates in your exported data, and prevents you from having to delete your existing data. This is good if you want to just add back lost data, without deleting data that's been changed / added since the last export.
There is also an INSERT INTO ... ON DUPLICATE KEY UPDATE ... that allows you to tell the query exactly what to do if there is a duplicate key. This prevents you from just ignoring two entries with identical keys that may not be identical entries. It is more complicated to setup properly, however.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With