Search code examples
mysqlwordpressdatabase-migrationmysql-error-1062

#1062 - Duplicate entry '1' in wordpress plugin table


When I'm importing a dump file from another existing website, it shows me the following error:

-- Duming data for table 'wp_cimy_uef_data'
--
INSERT INTO 'wp_cimy_uef_data' ('ID', 'USER_ID', 'FIELD_ID', 'VALUE') VALUES
(1, 1, 1, '');
--
#1062 Duplicate entry '1' for key PRIMARY (ID)

I've checked and there is an AUTO_INCREMENT on the ID. What can be the problem?

BTW, the plugin works just fine in the original website, only after dumping the DB to the new site it happens


Solution

  • You are trying to insert a 1 into the ID field rather than letting it be assigned by the AUTO_INCREMENT, and there is already an entry in your database with an ID value of 1.

    Omit the ID in your columns and values to have it auto assigned.

    INSERT INTO 'wp_cimy_uef_data' ('USER_ID', 'FIELD_ID', 'VALUE') 
    VALUES (1, 1, '');