How to recreate a table and restore from binary logs?
-
Configuration: Mandriva 2007 Linux, homebrew desktop dual processor athlon PC, 2x250GB hard drives, 4 GB RAM.
A few weeks ago, I noticed that my disk drive was full, when it should have only been about 20% full. I checked the disk, and found a bunch of unconnected inodes. I did an fsck and fixed the disk, and everything seemed OK.
Except… when started up the machine, all the comments in my blog were deleted with errors such as:
WordPress database error: [Can’t find file: ‘wp_comments’ (errno: 2)]
SELECT * FROM wp_comments WHERE comment_post_ID = ‘282’ AND comment_approved = ‘1’ ORDER BY comment_dateSo, I look at /var/lib/mysql, and find that, indeed, the comment table is missing.
The wp_comments.frm file exists, but not the wp_comments.MYD and wp_comments.MYI.
But, it turns out, that I have a ton of binary log files sitting there, and when I look at them, it seems that most of the comments are buried in there.
So, I google and read a bit on binary log files and it seems I ought to be able to reconstruct stuff using these files.
I try:
mysqlbinlog –database=billoblog mysql-bin.[0-9]* | mysql -pand get the error:
ERROR 1017 (HY000) at line 1721: Can’t find file: ‘wp_comments’ (errno: 2)
Doh.
So, do I need to recreate the table? Can I use the binary log to create it? Should I recreate it manually?
I’m really casting about here, and can’t seem to find a good tutorial on using the binary logs.
Can anybody point me towards an idiot guide to reconstruction? Any help would be appreciated.
Thanks in advance,
billo
- The topic ‘How to recreate a table and restore from binary logs?’ is closed to new replies.