thetechaddict
08-16-2006, 10:31 PM
I moved my MYBB forum to a new server. I imported the DB with phpmyadmin but am getting an error when trying to post a new thread (the forum displays correctly, and users can login fine).
The error is:
mySQL error: 1062
Duplicate entry '0' for key 1
Query: INSERT INTO mybb_threads (fid, subject, icon, uid, username, dateline, lastpost, lastposter, views, replies, visible) VALUES ('9', 'test', '0', '1', 'myusername', '1155781406', '1155781406', 'myusername', '0', '0', '1');
Note: "myusername" is where my real username went.
What can I do to fix this error? On the server im trying to import to, im running MySQL version 4 and phpMyAdmin 2.8.0.2.
maxymizer
08-17-2006, 01:28 AM
I think that the problem comes because there's allready a thread with fid = 9. This error usually arises when there's allready a primary key (or any other unique key) within the db and when you try to add another entry with the same key value.
How to solve it - honestly, without viewing your db or sql dump it's hard to say. Try manually changing the record of the thread that has fid = 9 to some other number (0 would be good) and after that run repair / optimize on that table.
maiahost
08-17-2006, 03:29 AM
if fid is auto_increment then you can run it without the 9 i.e. VALUES ('', 'test', etc.) however you should be check the db structure before doing so.
What version of mySQL was on the old server?
Apart from manually altering all the tables that are not set to autoincrement and should be, can you re-export the data from the old server? Add compatibility mode to your mysql dump, such as: --compatible=mysql40 (where 40 is the version you're moving to)
More info (http://www.google.com/search?hl=en&q=mysqldump+compatible&btnG=Google+Search)
thetechaddict
08-17-2006, 12:39 PM
What version of mySQL was on the old server?
Apart from manually altering all the tables that are not set to autoincrement and should be, can you re-export the data from the old server? Add compatibility mode to your mysql dump, such as: --compatible=mysql40 (where 40 is the version you're moving to)
More info (http://www.google.com/search?hl=en&q=mysqldump+compatible&btnG=Google+Search)
Well I had the database on the old server. Because I was cancelling my hosting I imported the database to mysql 5 on my home server, then i exported it with mysql 4 compatibility to my new web server.
Are you saying it's now working, or this process is what's left you with the issue?
thetechaddict
08-17-2006, 04:30 PM
This process left me with the issue. The site is thetechaddict.net/forums.
Tree NC
08-17-2006, 06:07 PM
The only prblem I see with your forums is that ' appears as "’", which is a problem. Just do a mysql replace to fix that problem.
As for the duplicate key problem, it often appears when you do a manual SQL dump from phpMyAdmin. It often doesn't include the auto-increment statement. The only way to fix it is to go in and manually set the auto_increment.