3

I know there is similar questions that are answered but please try to help me out.

I'm importing a backup of my MyBB database into a new host using PHPMyAdmin. When trying to import the .sql file, I get the following error:

SQL query:

INSERT INTO mybb_datacache(  `title` ,  `cache` ) 
VALUES (

'internal_settings',  'a:1:{s:14:\"encryption_key\";s:32:\"rrvohvVATtOauucNTmEXAmvNvbw9ujvb\";}'
);

MySQL said: 

#1062 - Duplicate entry 'internal_settings' for key 'PRIMARY'

I can't figure out the problem. I emptied all tables and clean install of the database four times already. I've been trying to figure this out all day and it's very frustrating.

(link removed)

Please help me out. How do I fix this problem?

Jaxidian
  • 13,081
  • 8
  • 83
  • 125
devs
  • 541
  • 2
  • 13
  • 27
  • You need to pull that file from where it's hosted. I'm guessing you don't know what's in that file but, for the sake of your job and whatever company/website you're helping, remove that file immediately! – Jaxidian Feb 05 '13 at 01:54
  • Why is the error message in the title different from the one in the body of the question? – Larry Lustig Feb 05 '13 at 02:03
  • A possible cause for the particular message mentioned in the title is the wrong type of the primary key column: set as numeric when supposed to be a string. – Andriy M Feb 05 '13 at 02:08
  • @Jaxidian Sorry. Frustrated and Didn't even realize what I just did. – devs Feb 05 '13 at 02:20

4 Answers4

5

When you export your sql from php admin

enter image description here

Select "custom" as export method"

enter image description here

then, instead of 'insert', choose "update"

This will perform update-statements and prevent duplicated inserts.

Gary Tsui
  • 1,755
  • 14
  • 18
  • Note that this can be a VERY expensive operation. I dumped a 320mb SQL file with `INSERT` originally and re-importing it took about 20 minutes, however there were issues. So I exported it with `UPDATE` and reimporting at the moment - we're currently in **hour 5** of the import process and no end in sight – indextwo Mar 21 '22 at 16:59
2

Make sure the column set as your PRIMARY KEY is set to AUTO_INCREMENT

John Conde
  • 217,595
  • 99
  • 455
  • 496
  • Yeah, sounds like a PK is either being defaulted to NULL or some other default value that's not unique. – Jaxidian Feb 05 '13 at 01:47
  • This happens in multiple columns. Is there anything I can do without re-uploading. Every time it comes up? – devs Feb 05 '13 at 01:48
  • Like can I open this into my editor and do a find and replace? Gotta be something... – devs Feb 05 '13 at 01:49
  • In this case it appears that the PRIMARY key is *not* an autoincrement column, but rather data (at least, it appears that way from the description in the body of the question if not from the title of the question). – Larry Lustig Feb 05 '13 at 02:03
0

From the current version of the question, it appears that the title column of the mybb_datacache table is the Primary Key and already has a record with the value 'internal_settings' in it. If this is indeed the case, then the problem is that all records must have unique values for their Primary Key.

Jaxidian
  • 13,081
  • 8
  • 83
  • 125
0

I had this problem, and i found what the problem is.

The thing is that, the field cannot be empty. ie, if you are altering a table to add primary key, make sure you have some values in that field. or if u are importing a sql file, make sure that that field in the file has some values....

this solved my problem...