Web Hosting Talk







View Full Version : Restoring a mySQL database - please help


Franki
08-06-2002, 04:24 PM
Hello. I have a mySQL database and I take daily backups with mysqldump. I restored the database some times but the last one (today) I get errors. I give the command "mysql -p database < database.sql" but it returns me the following error:

Error 1062 at line 777: Duplicate entry '34048-30284' for key 1

How can I fix it? A quick answer would be really appreciated! Thank you!

Lats
08-06-2002, 05:27 PM
Sounds like you haven't dropped all the tables before starting the restore.


Lats...

oasisland
08-06-2002, 09:03 PM
I assume one of the colum has been defined as a primary key, in which you have a dupicated value in you backup data.

stbauer
08-07-2002, 02:06 AM
This can sometimes be caused by corrupt index tables (the .MYI files). Try running myisamchk first on those indices:

cd /path/to/database/dir
myisamchk *.MYI

Alternatively, if you are sure that your backup contains the correct and up to date data, you can simply drop the current table, recreate it, and fill the new empty table with the data from the backup.