0

I am trying to import a MySQL database into the localhost database that was exported from the remote database and I am receiving a #1062 error (which is weirdly in French!):

#1062 - Duplicata du champ '1' pour la clef 'PRIMARY'

Google translate: # 1062 - Duplicate field '1' for key 'PRIMARY'

The code that it highlights is as follows:

--
-- Dumping data for table `exp_accessories`
--

INSERT INTO `exp_accessories` (`accessory_id`, `class`, `member_groups`, `controllers`, `accessory_version`) VALUES
(1, 'Expressionengine_info_acc', '1|5', 'content|members|admin_content|design|tools_communicate|homepage|addons_fieldtypes|content_files|admin_system|tools_data|addons|tools|tools_logs|tools_utilities|addons_accessories|content_files_modal|myaccount|addons_modules|addons_plugins|content_publish|content_edit|addons_extensions', '1.0'),
(2, 'Cartthrob_acc', '1|5', 'content|members|admin_content|design|tools_communicate|homepage|addons_fieldtypes|content_files|admin_system|tools_data|addons|tools|tools_logs|tools_utilities|addons_accessories|content_files_modal|myaccount|addons_modules|addons_plugins|content_publish|content_edit|addons_extensions', '1.0');

I am a novice with SQL and I can't see what it is on about. I can't see a duplicate in the primary key, the accessory_ids appear to be 1 and 2? Am I missing something here? And why is there a duplicate here and not on the remote server?

Many thanks

Gabe

1
  • What it's saying is there is already a record in the table with primary key = 1. – Colin 't Hart Sep 12 '14 at 12:02
1

Your local table is likely not empty, thus the error when conflicting with existent data. If you do not want to keep any of the current data, you need to delete all rows before the insert. One fast way to do that is with:

TRUNCATE TABLE exp_accessories;

Usually, mysqldump will drop the table before import, like this:

DROP TABLE IF EXISTS `exp_accessories`;

Regarding French, client sessions can change the default language setting by doing SET lc_messages = 'en_US'; and receive error messages in a different language.

1

This error is usually generated when there is already an existing value in a column which is defined as a primary key in the table that you are inserting into. I'd go back to design and make sure that 'accessory_id' is set as AUTO_INCREMENT and then insert the data itself and run:

INSERT INTO `exp_accessories` (`class`, `member_groups`, `controllers`, `accessory_version`) VALUES
    ('Expressionengine_info_acc', '1|5', 'content|members|admin_content|design|tools_communicate|homepage|addons_fieldtypes|content_files|admin_system|tools_data|addons|tools|tools_logs|tools_utilities|addons_accessories|content_files_modal|myaccount|addons_modules|addons_plugins|content_publish|content_edit|addons_extensions', '1.0'),
    ('Cartthrob_acc', '1|5', 'content|members|admin_content|design|tools_communicate|homepage|addons_fieldtypes|content_files|admin_system|tools_data|addons|tools|tools_logs|tools_utilities|addons_accessories|content_files_modal|myaccount|addons_modules|addons_plugins|content_publish|content_edit|addons_extensions', '1.0');

If you absolutely must have the same 'accessory_id' in your localhost db to the one that you're importing from then you will need to ensure that there is no data entered into that table, I suspect you've added a record on accident or something like that seeing as you said you're a novice =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.